如何在每个工作区中配置不带.clang格式文件的clang格式?

Chr*_* S. 6 clang-format visual-studio-code vscode-settings

我想配置clang格式,而不必将我的.clang-format文件复制到每个新的工作区中。

在我settings.json目前

"C_Cpp.clang_format_style": "{BasedOnStyle: Google, IndentWidth: 4, IndentCaseLabels: false, TabWidth: 4, UseTab: ForIndentation, ColumnLimit: 0}",
"C_Cpp.clang_format_fallbackStyle": "Google"
Run Code Online (Sandbox Code Playgroud)

描述了C_Cpp.clang_format_style

编码样式,当前支持:Visual Studio,LLVM,Google,Chromium,Mozilla,WebKit。使用“文件”从当前目录或父目录中的.clang格式文件加载样式。使用“ {键:值,...}”设置特定的参数,例如:“ {BasedOnStyle:LLVM,IndentWidth:8}”

这让我认为我的方法行得通,但事实并非如此。当我使用自动格式时,它始终使用Google fallbackStyle。

这是不可能的还是我在这里做错了什么?

joe*_*err 1

我刚刚遇到了同样的问题,发现您的方法使用(我只更改了格式)

"C_Cpp.clang_format_style": "{BasedOnStyle: Google, 
IndentWidth: 4, 
IndentCaseLabels: false, 
TabWidth: 4, UseTab: ForIndentation, 
ColumnLimit: 0}",
Run Code Online (Sandbox Code Playgroud)

确实有效。