VSCode-禁用C代码的注释自动格式化

时间:2020-11-12 14:56:39

标签: c visual-studio-code code-formatting prettier

我刚刚在vscode中安装了一个更漂亮的扩展名来自动格式化我的代码。但是,我代码中的所有注释都向左移动。我不要 格式化之前: enter image description here

格式化后: enter image description here

问题是我希望我的评论保持原样。我不希望他们被感动。我绝对满意的其他东西。我只希望格式化时忽略注释。

有可能吗?如果可以的话,您可以帮我吗?它并不仅限于Prettier扩展。如果需要,我打算使用其他格式扩展名。谢谢。

1 个答案:

答案 0 :(得分:0)

对于VSCode,您可以编辑settings.json文件以指定默认的clang格式后备样式。本文档将告诉您可用于设置的所有参数:Locator Strategies

我的设置供参考:

    "C_Cpp.clang_format_fallbackStyle": " {BasedOnStyle: Google, AllowShortCaseLabelsOnASingleLine: true, AlignConsecutiveDeclarations: true, AllowShortFunctionsOnASingleLine: All, AlignTrailingComments: true, Language: Cpp, AlwaysBreakAfterReturnType: None, PenaltyReturnTypeOnItsOwnLine: 9999, PointerAlignment: Left, SortIncludes: true, IndentWidth: 4, ColumnLimit: 0, BreakBeforeBraces: Allman, SpacesBeforeTrailingComments: 5, AlignAfterOpenBracket: true, AlignConsecutiveAssignments: true, AlignConsecutiveMacros : true}",