打字时如何设置 VSCode 以在 C# 和 C++ 中的新行上放置花括号?

Mik*_*eev 6 c# formatting unity-game-engine visual-studio-code vscode-settings

我希望 VS Code 将花括号放在 C# 和 C++ 中的新行上

现在如何运作 现在如何运作

它应该看起来如何 它应该看起来如何

尝试过 C# FixFormat 扩展,但它只有在我按下 CTRL+K+F 后才有效,但我希望 VS Code 在我编码时在新行上加上花括号,而不需要额外的步骤,如热键等

小智 8

现在 C#FixFormat 已被删除,请尝试omnisharp.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
    }
}
Run Code Online (Sandbox Code Playgroud)


小智 0

在 VSCode 上,转到 File\Preferences\Settings 并搜索“curly”。启用图中所示的所有四个打字稿。

大括号

  • 已经尝试过了,似乎它不会影响 C# 和 C++ 格式 (3认同)