如何在每个工作区中配置没有 .clang-format 文件的 clang 格式? [英] How can i configure clang format without .clang-format file in every workspace?

查看:89
本文介绍了如何在每个工作区中配置没有 .clang-format 文件的 clang 格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to configure clang-format without having to copy my .clang-format file to every new workspace.

在我的 settings.json 中,我目前有

In my settings.json I currently have

"C_Cpp.clang_format_style": "{BasedOnStyle: Google, IndentWidth: 4, IndentCaseLabels: false, TabWidth: 4, UseTab: ForIndentation, ColumnLimit: 0}",
"C_Cpp.clang_format_fallbackStyle": "Google"

C_Cpp.clang_format_style 的描述说

编码风格,目前支持:Visual Studio、LLVM、Google、Chromium、Mozilla、WebKit.使用file"从当前或父目录中的 .clang 格式文件加载样式.使用{key: value, ...}"设置具体参数,例如:{ BasedOnStyle: LLVM, IndentWidth: 8 }"

Coding style, currently supports: Visual Studio, LLVM, Google, Chromium, Mozilla, WebKit. Use "file" to load the style from a .clang-format file in the current or parent directory. Use "{key: value, ...}" to set specific parameters, e.g.: "{ BasedOnStyle: LLVM, IndentWidth: 8 }"

这让我认为我的方法可行,但事实并非如此.当我使用自动格式时,它总是使用 Google fallbackStyle.

Which made me think my approach would work, which it doesn't. When I use the auto format it always uses the Google fallbackStyle.

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

Is this just not possible or am I doing something wrong here?

推荐答案

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

I just had the same problem and found that your approach using (I have changed only the formatting)

"C_Cpp.clang_format_style": "{BasedOnStyle: Google, 
IndentWidth: 4, 
IndentCaseLabels: false, 
TabWidth: 4, UseTab: ForIndentation, 
ColumnLimit: 0}",

确实有效.

这篇关于如何在每个工作区中配置没有 .clang-format 文件的 clang 格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆