4

In my current uncrustify configuration, if a function is called, most of the time the arguments are aligned to the opening parenthesis which is what I want.

However, if the first argument is long such that the line width (code_width) is exceeded the following occurs:

  1. A newline is appended after the opening parenthesis
  2. The arguments are aligned but dedented with respect to the opening brace.

So this:

        printf("This is some very large example string, which is so large, it exceeds the max line width",
               some_arg1,
               some_arg2,
               some_arg3);

Becomes this:

        printf(
            "This is some very large example string, which is so large, it exceeds the max line width",
            some_arg1,
            some_arg2,
            some_arg3);

Is there any way I can ensure that the function call's arguments are all aligned as in my first snippet?

Some of the options in my cfg file which I think might be related:

# True:  indent continued function call parameters one indent level
# False: align parameters under the open paren.
indent_func_call_param          = false    # false/true

# Add or remove newline after '(' in a function declaration.
nl_func_decl_start              = remove   # ignore/add/remove/force

# Add or remove newline after '(' in a function definition.
nl_func_def_start               = remove   # ignore/add/remove/force

# Whether to add newline after '(' in a function declaration if '(' and ')' are in different lines.
nl_func_decl_start_multi_line   = false    # false/true

# Whether to add newline after '(' in a function definition if '(' and ')' are in different lines.
nl_func_def_start_multi_line    = false    # false/true

# Whether to add newline after '(' in a function call if '(' and ')' are in different lines.
nl_func_call_start_multi_line   = false    # false/true

# True:  indent continued function call parameters one indent level
# False: align parameters under the open paren.
indent_func_call_param          = false    # false/true

# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended).
indent_paren_nl                 = false    # false/true
JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Gregory Kuhn
  • 1,627
  • 2
  • 22
  • 34
  • Try some of the `align_*` options found [here](http://uncrustify.sourceforge.net/config.txt) – smac89 May 14 '21 at 08:32

0 Answers0