Adding newline after if-else block using uncrustify

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 two solve this? I want a new line between multiple ifs.

Answers

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.

Posted on by Matthew