I have a C++ function call that I've manually and intentionally formatted like this:
DoSomethingForAPurposeThatCausesALongFunctionName(
arg_0,
arg_1,
arg_2);
clang-format wants to re-format it like this:
DoSomethingForAPurposeThatCausesALongFunctionName(
arg_0, arg_1, arg_2)
I do not want this. AllowAllParametersOfDeclarationOnNextLine
appears to
control this behavior for function declarations, but what about function calls?
Is there a corresponding setting?
My .clang-format
looks like this:
BasedOnStyle: Google
BinPackArguments: false
BinPackParameters: false
AllowAllParametersOfDeclarationOnNextLine: false
AlignAfterOpenBracket: AlwaysBreak
I'm also interested in preventing multiple arguments on the same line, but below the fun(
line. In my case, I don't mind if the first argument is still on the same line as fun(
. I just want them to either be all on the fun(
line or all stacked.
I was able to achieve this by increasing PenaltyBreakBeforeFirstCallParameter
to 100.
Presumably you may need a different value depending on your other penalty settings.
This yields:
fun(my_long_argument_0,
my_long_argument_1,
my_long_argument_2);
In your case, assuming DoSomethingForAPurposeThatCausesALongFunctionName(arg_0,
is too long for one line, it would yield:
DoSomethingForAPurposeThatCausesALongFunctionName(
arg_0,
arg_1,
arg_2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With