Is there a way to enable Whitesmiths style (sometimes termed Wishart style) * which is similar to "Allman style"?
I would be very happy about implementation
PS: I don't want to discuss about personal visual preferences.
Is there a way to enable Whitesmiths style (sometimes termed Wishart style) * which is similar to "Allman style"?
I would be very happy about implementation
PS: I don't want to discuss about personal visual preferences.
Hello,
Thank you for the question. Right now we do not have any option for this. But our formatter is customizable internally, so it might be a good idea (if there is an interest) to allow users to configure their own code style. That way it would be possible to set it for Whitesmiths style, or any other style.
We'll keep you posted.
Thank you!
Thank you! Customizable formatter would be a great feature!
Customizable formatter will be present in the upcoming pre-release.
Ability to setup Whitesmiths style will come next ;-)
Thank you for the suggestion
The next pre-release will have php.format.rules.indentBraces
option. Together with php.format.codeStyle
set to allman
should give you Whitesmiths style
Thank you!
Cool, thanks!
It seems to work in most cases after hitting ;
But there might be some irritation:
function t():void{echo 1;}
results in
function t(): void
{
echo 1;}
Enter after ; results in
function t(): void
/*tab*/ {
/*tab*/ echo 1;
} // no tab !
function d(
autocompletes to
function d()
with cursor between () // good
[end]{
autocompletes to
function d(){}
with cursor between {} // good
When adding
echo 1;
nothing happens.
Only after removing } and adding new } the desired result is
function d()
{
echo 2;
}
settings.json:
// Legacy:
"typescript.format.placeOpenBraceOnNewLineForFunctions": true,
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false,
"editor.detectIndentation": false,
// php.format:
"php.format.codeStyle": "Allman",
"php.format.rules.indentBraces": true,
Format document (Ctrl Shift I) does nothing at
function p(): bool
{
return true;} //last line
Only if there is following line the } will be on desired position.
<?php
if (mt_rand())
{
echo 2;
}
else
echo 3;
echo 4;
gets formatted as desired first after echo 4; which is strange if adding single lines to existing code.
Moving the last line into up to {} (by Alt+Arrow up) and down again results in
<?php
if (mt_rand())
{
echo 2;
}
else
echo 3;
echo 4;
Using
<?php
if (mt_rand())
{
echo 2;
}
else
echo 3;
echo 4;
and copying last line by CTRL+C (with just cursor in this line), moving cursor in the line after else (e.g. between echo and 3) and CTRL+V results in
<?php
if (mt_rand())
{
echo 2;
}
else
echo 4;
echo 3;
echo 4;
instead of indented first "echo 4";