VSCode format curly brackets on the same line c#

时光总嘲笑我的痴心妄想 提交于 2020-02-01 10:12:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!