why*_*hy2 5 c++ code-formatting visual-studio-code
到目前为止,在安装C ++扩展工具之后,我可以使用ctrl + K + F自动格式化我的C ++代码。但是,我想进行一些修改,例如,我想强制指针对齐在类型附近,而不是在变量名旁边,例如以下规则:
# Force pointers to the type for C++.
DerivePointerAlignment: false
PointerAlignment: Left
Run Code Online (Sandbox Code Playgroud)
我该如何修改?我试图创建一个.clang格式的文件,但是它不起作用。
经过一些实验,简单的解决方案是在用户设置(settings.json)中添加这一行:
"C_Cpp.clang_format_fallbackStyle": "{ PointerAlignment: Left}"
但是,此设置允许我保留以前的设置而不会破坏我的功能线:
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: WebKit, ColumnLimit: 120, PointerAlignment: Left}"
使用“BasedOnStyle:Visual Studio”,例如这一行:
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Visual Studio, ColumnLimit: 120, PointerAlignment: Left}"
不起作用。这可能是一个错误。我使用了 Visual Studio Code 1.26.1 版。
此外,仍将应用工作区文件夹之外的 .clangformat。因此,如果此文件已损坏,则自动格式化将不起作用。
归档时间: |
|
查看次数: |
4119 次 |
最近记录: |