Setting up VSCode: Difference between revisions
Marcus Green (talk | contribs) Created page with "VSCode stub https://en.wikipedia.org/wiki/Visual_Studio_Code" |
Marcus Green (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
VSCode stub | VSCode stub | ||
https://en.wikipedia.org/wiki/Visual_Studio_Code | 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 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 | |||
<code php> | |||
{ | |||
"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 | |||
} | |||
} | |||
</code> | |||
Revision as of 19:54, 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 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
}
}