问题
When using the Format Document command I'd like to change how the code formats. I'm completely new to VSCode and I'm still having trouble navigating the settings, so easy to understand replies would be very helpful. Currently the code is formatting like this:
void start ()
{
//Do stuff here
}
I want it to look like:
void start () {
//Do stuff here
}
回答1:
I have found this simple solution for VScode !
Just create a file called omnisharp.json at the root of your project and paste the following JSON :
{
"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
}
}
I found the solution here: https://medium.com/@wearetherock/visual-studio-code-c-put-the-opening-brace-on-the-same-line-as-the-statement-a98c552a544b
来源:https://stackoverflow.com/questions/49136015/vscode-format-curly-brackets-on-the-same-line-c-sharp