如何将 VSCode 的 clang-format 扩展的缩进更改为 4?

问题描述 投票:0回答:2

clang-format 命令行允许定义缩进宽度,例如

clang-format -style="{IndentWidth: 4}"  myfile.cpp

我在 Ubuntu linux 上安装了 VSCode 的 clang-format 扩展,我在扩展配置中没有看到缩进配置。

有没有办法让扩展名缩进4?

visual-studio-code clang-format
2个回答
0
投票

简短的解决方案:在项目根目录创建一个

.clang-format
,其中包含以下内容:

# .clang-format
IndentWidth: 4

vscode-clang-format 似乎没有维护,但是,vscode 的 clangd 扩展附带了默认的格式化程序支持。根据 clangd 存储库的 README,格式由项目根目录下的

.clang-format
文件控制。这是文档,以防您需要。

可能有点晚了,但希望这会有所帮助。


-2
投票

在 clang-format 扩展设置中,您可以使用“Clang-format: Style”来给出特定选项。

示例:

{缩进宽度:4}

© www.soinside.com 2019 - 2024. All rights reserved.