Jonathan Sharman
Jonathan Sharman

Reputation: 636

How can I make clang-format put the first arg/param on its own line when arguments are split into lines?

I have the following .clang-format settings (among others, but these are the relevant ones AFAIK):

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

What clang-format does (and similar for function calls):

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

What I want it to do:

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

I.e., I want to keep all the parameters/arguments left aligned, but I don't want to align everything to the open paren. Is this possible?

Upvotes: 0

Views: 128

Answers (1)

Jonathan Sharman
Jonathan Sharman

Reputation: 636

Not a totally satisfactory answer, but better than nothing: add an empty line comment after the open parenthesis.

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

This forces clang-format to align the first item with the others.

Upvotes: 1

Related Questions