1

Is there a way to introduce a new line after if-else block? Current code looks like this:

if (condition) {
}
else {
}
if (condition) {
}
statement;

I want to make it look like this:

if (condition) {
}
else {
}

if (condition) {
}

statement;

I have setup

nl_after_if=force

but it doesn't seem to help.

EDIT: nl_after_if=force doesn't introduce a new line between to if blocks. The output is this:

if (condition) {
}
else {
}
if (condition) {
}

statement;

Which is potentially more confusing. Is there a way to solve this? I want a new line between multiple ifs.

Anupam Srivastava
  • 789
  • 1
  • 8
  • 25
  • Possible duplicate of [Blank line after curly brace in function with uncrustify](https://stackoverflow.com/questions/7163294/blank-line-after-curly-brace-in-function-with-uncrustify) – Pablo Oliva Nov 14 '17 at 21:08

1 Answers1

1

I don't think there is an option for that. However, maybe nl_before_if is close enough? (It will add the newline you are asking for in exactly your above example, at least.)

Although, it's not entirely obvious what nl_after_if is supposed to do. My guess from the documentation would be that it adds a newline if (expr)<HERE>expr, but it does seem to also add one between an if-chain and a following non-if statement, which seems inconsistent. In any case, you might want to consider filling an issue.

Matthew
  • 2,593
  • 22
  • 25