6
Vscode配置clang-Format的tabWidth
source link: https://shingle.me/post/vscode%E9%85%8D%E7%BD%AEclang-format%E7%9A%84tabwidth/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Vscode配置clang-Format的tabWidth
2019-03-27 14:03:58
约 407 字
预计阅读 1 分钟
2084 次阅读
接着上上篇 Vscode配置proto插件, 在装了 clang-format插件后,我发现格式化完的 proto 文件tabwidth 默认为2, 看起来很别扭
网上搜索得到的大部分解决方案是: 修改 vscode 里的C_Cpp.clang_format_fallbackStyle
配置, 该配置的默认值为Visual Studio
,改为 Google
或者LLVM
"C_Cpp.clang_format_fallbackStyle":"Google"
这个修改解决的是{}
花括号会换行的格式问题,
//不换行
func a{
}
//会换行
func a
{
}
可能是vscode 已经默认使用了左花括号不换号的行为, 所以修改了这个选项并没有任何反应.
还有人提出可以在该设置中添加额外选项:
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, IndentWidth: 4, TabWidth: 4 }"
经测试发现也没有效果, 我甚至把clang-format
能设置的选项都加上了
其实很简单, 新建一个~/.clang-format
文件,添加一行, 在格式化时clang-format
会默认使用该配置文件
IndentWidth: 4
是我想要的效果是四个空格的缩进
赞赏支持
赞赏列表
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK