SAS*_*ROG 4 c c++ visual-studio-code
所以我正在C使用 vscode 进行一个学校项目。我们彻底评分的最重要的事情之一是整洁的代码格式。假设我已经声明了 3 个这样的变量
int i;
char *s;
size_t t;
Run Code Online (Sandbox Code Playgroud)
它们必须像这样完全对齐。"editor.formatOnSave": true现在在 settings/settings.json` 中启用 vscode会将其更改为
int i;
char *s;
size_t t;
Run Code Online (Sandbox Code Playgroud)
现在 vscode 中有一种方法可以像第一个片段一样以特定方式保持这些变量对齐,或者自动完成对齐吗?
使用 C/C++ 扩展,您可以配置格式化程序。使用AlignConsecutiveDeclarationsfrom clang-format来对齐这样的变量。
配置示例(对于C_Cpp.clang_format_style):
{ BasedOnStyle: LLVM, AlignConsecutiveDeclarations: true }
Run Code Online (Sandbox Code Playgroud)
所以settings.json你可以有这样的东西:
{
"C_Cpp.clang_format_style": "{ BasedOnStyle: LLVM, AlignConsecutiveDeclarations: true }",
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9861 次 |
| 最近记录: |