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

后端 未结 8 1461
后悔当初
后悔当初 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

    You can make some changes from the "Settings". For example javascript rules start with "javascript.format". But for advanced formatting control, still need to use some extensions.

    Rules settings for the format code command

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题