Setting up VSCode: Difference between revisions
Marcus Green (talk | contribs) No edit summary |
Marcus Green (talk | contribs) |
||
Line 10: | Line 10: | ||
"the brace should always be written on same line as the function name." | "the brace should always be written on same line as the function name." | ||
By default VSCode uses the PSR coding convention that braces appear on the next line when the internal formatter is used. | By default VSCode uses the PSR coding convention | ||
https://www.php-fig.org/psr/psr-2/#1-overview | |||
that braces appear on the next line when the internal formatter is used. | |||
(Cmd -K-F on OSX). | (Cmd -K-F on OSX). | ||
This can be changed via a file called | This can be changed via a file called | ||
Revision as of 20:02, 6 August 2019
VSCode stub https://en.wikipedia.org/wiki/Visual_Studio_Code
Location of function/class braces
According to the Moodle coding guidelines
https://docs.moodle.org/dev/Coding_style#Functions_and_methods_2
"the brace should always be written on same line as the function name."
By default VSCode uses the PSR coding convention https://www.php-fig.org/psr/psr-2/#1-overview that braces appear on the next line when the internal formatter is used. (Cmd -K-F on OSX).
This can be changed via a file called
omnisharp.json
Which can be placed either in the root of the project or as a configuration in the users home dir, e.g. ~/.omnisharp/omnisharp.json
The following example will put braces on the same line as the function/class declaration
{
"FormattingOptions": {
"NewLinesForBracesInLambdaExpressionBody": false,
"NewLinesForBracesInAnonymousMethods": false,
"NewLinesForBracesInAnonymousTypes": false,
"NewLinesForBracesInControlBlocks": false,
"NewLinesForBracesInTypes": false,
"NewLinesForBracesInMethods": false,
"NewLinesForBracesInProperties": false,
"NewLinesForBracesInObjectCollectionArrayInitializers": false,
"NewLinesForBracesInAccessors": false,
"NewLineForElse": false,
"NewLineForCatch": false,
"NewLineForFinally": false
}
}