How do you change the formatting options in Visual Studio Code?

后端 未结 8 1465
后悔当初
后悔当初 2020-12-07 19:37

I know you can Format Code using Ctrl+F / Cmd+F in Visual Studio Code but how do you change the formatting options for each langu

8条回答
  •  离开以前
    2020-12-07 20:37

    To change specifically C# (OmniSharp) formatting settings you can use a json file:
    User: ~/.omnisharp/omnisharp.json or %USERPROFILE%\.omnisharp\omnisharp.json
    Workspace: omnisharp.json file in the working directory which OmniSharp has been pointed at.

    Example:

    {
      "FormattingOptions": {
        "NewLinesForBracesInMethods": false,
        "NewLinesForBracesInProperties": false,
        "NewLinesForBracesInAccessors": false,
        "NewLinesForBracesInAnonymousMethods": false,
        "NewLinesForBracesInControlBlocks": false,
        "NewLinesForBracesInObjectCollectionArrayInitializers": false,
        "NewLinesForBracesInLambdaExpressionBody": false
      }
    }
    

    Details on this post | omnisharp.json schema (it's already in vscode, you can just CTRL+SPACE it)

    Other language extensions may have similar files for setting it.

提交回复
热议问题