我面临着铿锵格式结果的一些麻烦。顺便说一句,我正在使用v3.8.0.246435。
请考虑以下代码示例:
if(foo)
{
bar();
foobar(
arg1,
arg2,
arg3,
arg4,
arg5,
arg6);
}
在上面的代码中,所有内容都缩进了3个空格。 现在,如果我在这段代码上运行clang-format(请参阅我的帖子底部的clang-format配置),我得到以下输出:
if(foo)
{
/*V 3 spaces here */
bar();
foobar(
arg1,
arg2,
arg3,
arg4,
arg5,
arg6);
/*^ 4 spaces here */
}
我发现这是一种非常奇怪的行为。我想在整个代码中使用相同的缩进级别。似乎clang-format总是用4个空格缩进函数参数/参数,无论IndentWidth
具有什么值。有没有办法覆盖这种行为?或者这是一个错误吗?
我的铿锵格式cfg:
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
答案 0 :(得分:1)
实际上,我发现哪个命令丢失了。你必须添加
ContinuationIndentWidth: 3
或您想要的任何数字,以便它以您想要的方式缩进连续的行。默认值为4。