当参数拆分为行时,如何使clang-format将第一个arg / param放在自己的行上?

时间:2019-01-26 18:40:54

标签: c++ clang-format

我有以下.clang-format设置(除其他设置外,这些都是AFAIK的相关设置):

AlignAfterOpenBracket: 'DontAlign'
AllowAllParametersOfDeclarationOnNextLine: 'false'
BinPackArguments: 'false'
BinPackParameters: 'false'

clang-format的作用(与函数调用类似):

void this_is_a_function(int first_param,
    int second_param,
    int third_param);

我想要它做什么:

void this_is_a_function(
    int first_param,
    int second_param,
    int third_param);

也就是说,我想使所有参数/参数保持对齐,但我不想将所有参数/参数都与打开的括号对齐。这可能吗?

1 个答案:

答案 0 :(得分:0)

不是一个完全令人满意的答案,但总比没有好:在右括号后添加一个空行注释。

void this_is_a_function( //
    int first_param,
    int second_param,
    int third_param);

这会强制clang格式将第一项与其他项对齐。