clang 格式缩进函数 arguments/parameters 总是有 4 个空格
clang-format indents function arguments/parameters always with 4 spaces
我在 clang-format 输出方面遇到了一些麻烦。顺便说一句,我使用的是 v3.8.0.246435。
考虑以下代码示例:
if(foo)
{
bar();
foobar(
arg1,
arg2,
arg3,
arg4,
arg5,
arg6);
}
在上面的代码中,所有内容都缩进了 3 个空格。
现在,如果我在此代码上 运行 clang-format(请参阅我的 post 的底部以了解我的 clang-format 配置),我会得到以下输出:
if(foo)
{
/*V 3 spaces here */
bar();
foobar(
arg1,
arg2,
arg3,
arg4,
arg5,
arg6);
/*^ 4 spaces here */
}
我发现这是一个非常奇怪的行为。我想要在整个代码中使用相同的缩进级别。似乎 clang-format 总是将函数 arguments/parameters 缩进 4 个空格,无论 IndentWidth
的值是多少。有没有办法覆盖这种行为?或者这是一个错误?
我的 clang 格式配置文件:
Language: Cpp
SpaceBeforeParens: Never
SpacesInParentheses: false
SpaceAfterCStyleCast: true
SpacesInSquareBrackets: false
AllowShortIfStatementsOnASingleLine: false
PointerAlignment: Right
AlignOperands: true
AlignConsecutiveAssignments: true
AlignAfterOpenBracket: false
UseTab: Never
IndentWidth: 3
TabWidth: 3
ColumnLimit: 100
MaxEmptyLinesToKeep: 4
KeepEmptyLinesAtTheStartOfBlocks: false
BreakBeforeBraces: Stroustrup
BinPackArguments: false
BinPackParameters: false
AllowShortFunctionsOnASingleLine: None
AlignEscapedNewlinesLeft: true
其实我发现少了哪个命令。您必须添加
ContinuationIndentWidth: 3
或者你想要的任何数字,以便它按照你想要的方式缩进连续的行。默认为 4。
我在 clang-format 输出方面遇到了一些麻烦。顺便说一句,我使用的是 v3.8.0.246435。
考虑以下代码示例:
if(foo)
{
bar();
foobar(
arg1,
arg2,
arg3,
arg4,
arg5,
arg6);
}
在上面的代码中,所有内容都缩进了 3 个空格。 现在,如果我在此代码上 运行 clang-format(请参阅我的 post 的底部以了解我的 clang-format 配置),我会得到以下输出:
if(foo)
{
/*V 3 spaces here */
bar();
foobar(
arg1,
arg2,
arg3,
arg4,
arg5,
arg6);
/*^ 4 spaces here */
}
我发现这是一个非常奇怪的行为。我想要在整个代码中使用相同的缩进级别。似乎 clang-format 总是将函数 arguments/parameters 缩进 4 个空格,无论 IndentWidth
的值是多少。有没有办法覆盖这种行为?或者这是一个错误?
我的 clang 格式配置文件:
Language: Cpp
SpaceBeforeParens: Never
SpacesInParentheses: false
SpaceAfterCStyleCast: true
SpacesInSquareBrackets: false
AllowShortIfStatementsOnASingleLine: false
PointerAlignment: Right
AlignOperands: true
AlignConsecutiveAssignments: true
AlignAfterOpenBracket: false
UseTab: Never
IndentWidth: 3
TabWidth: 3
ColumnLimit: 100
MaxEmptyLinesToKeep: 4
KeepEmptyLinesAtTheStartOfBlocks: false
BreakBeforeBraces: Stroustrup
BinPackArguments: false
BinPackParameters: false
AllowShortFunctionsOnASingleLine: None
AlignEscapedNewlinesLeft: true
其实我发现少了哪个命令。您必须添加
ContinuationIndentWidth: 3
或者你想要的任何数字,以便它按照你想要的方式缩进连续的行。默认为 4。