3

I've been working on my uncrustify config for a few hours now and I'm very close to having it the way I need it. However, I can't find an option to control newlines between function bodies. Uncrustify always removes blank lines between functions, but I'd like to enforce one blank line. Currently I get this:

Input:

void foo() {
  std::cout << "foo!" << std::endl;
}

void bar() {
  std::cout << "bar!" << std::endl;
}

Output:

void foo() {
  std::cout << "foo!" << std::endl;
}
void bar() {
  std::cout << "bar!" << std::endl;
}

In my case, I'd like to preserve (force!) the blank line in the input. Is there an option to control this?

Pat Notz
  • 208,672
  • 30
  • 90
  • 92

1 Answers1

10

Epiphany - I was miscounting 'newlines'. The configuration option for this is:

# The number of newlines after '}' of a multi-line function body
nl_after_func_body                       = 2        # number

I originally set this to 1. However, Uncrustify includes the newline on the line containing the brace (}). Setting this to 2 gives the desired result.

Pat Notz
  • 208,672
  • 30
  • 90
  • 92