Home > database >  How to make clang-format not align parameters to function call?
How to make clang-format not align parameters to function call?

Time:04-02

I want to make clang-format not align call parameters to the '(' symbol. I had tried setting PenaltyBreakBeforeFirstCallParameter to 0, but it didn't help.

How I want it to be:

veeeeeeeryLongFunctionName(
    longParameter1, longParameter2,
    longParameter3, longParameter4
)

// or

veeeeeeeryLongFunctionName(
    loooooooooongParameter1,
    loooooooooongParameter2,
    loooooooooongParameter3,
    loooooooooongParameter4
)

How clang-format does it:

veeeeeeeryLongFunctionName(loooooooooongParameter1,
                           loooooooooongParameter2,
                           loooooooooongParameter3,
                           loooooooooongParameter4
)

CodePudding user response:

You can use

AlignAfterOpenBracket : BlockIndent

Always break after an open bracket, if the parameters don’t fit on a single line. Closing brackets will be placed on a new line. E.g.:

someLongFunction(
   argument1, argument2
)

Reference

  • Related