如何解决VSCode-禁用C代码的注释自动格式化
我刚刚在vscode中安装了一个更漂亮的扩展名来自动格式化我的代码。但是,我代码中的所有注释都向左移动。我不要 格式化之前: enter image description here
格式化后: enter image description here
问题是我希望我的评论保持原样。我不希望他们被感动。我绝对满意的其他东西。我只希望格式化时忽略注释。
有可能吗?如果可以的话,您可以帮我吗?它并不仅限于Prettier扩展。如果需要,我打算使用其他格式扩展名。谢谢。
解决方法
对于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}",
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。