【问题标题】:Is there anyway to get VS Code to auto format curly brackets on new line for C#?反正有没有让 VS Code 在 C# 的新行上自动格式化大括号?
【发布时间】:2022-01-16 08:59:41
【问题描述】:

有没有办法设置 vscode 来自动格式化大括号以换行。我最近不得不从 Visual Studio 切换到 vscode,并试图让它像我拥有我的 Visual Studio 一样运行,这样我就可以完全回到我通常的工作流程。 Ive 发布了一些关于一些扩展的帖子,这些扩展可能会执行此操作,但它们要么无法正常运行,要么不再可用。感谢您的帮助

【问题讨论】:

标签: c# unity3d visual-studio-code formatting vscode-settings


【解决方案1】:

要让 VSCode 添加一个新行来打开花括号,请在 Unity 项目的根目录(在 Assets 文件夹旁边)创建一个名为 omnisharp.json 的文件,其中包含以下内容,然后重新启动 VSCode。

{
    "FormattingOptions": {
        "NewLinesForBracesInLambdaExpressionBody": true,
        "NewLinesForBracesInAnonymousMethods": true,
        "NewLinesForBracesInAnonymousTypes": true,
        "NewLinesForBracesInControlBlocks": true,
        "NewLinesForBracesInTypes": true,
        "NewLinesForBracesInMethods": true,
        "NewLinesForBracesInProperties": true,
        "NewLinesForBracesInObjectCollectionArrayInitializers": true,
        "NewLinesForBracesInAccessors": true,
        "NewLineForElse": true,
        "NewLineForCatch": true,
        "NewLineForFinally": true
    }
}

【讨论】:

  • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-12-24
  • 1970-01-01
  • 2021-04-03
  • 2022-01-13
  • 2020-07-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多