nl_if_brace
Add or remove newline between 'if' and '{'.
Possible values are ignore, add, remove and force.
Note:
- one-line expression gets edited by default; there is nl_if_leave_one_liners option to change this behavior
- the else part is not affected; there is similar option nl_else_brace to control this
Examples
Add
Before:
// One-line if
if (x<15) y=30;
// Single if
if (x<5) {
std::cout << "x is less than 5" << '\n';
}
// if with else
if (x<y) {
std::cout << "Also x is less than " << y << '\n';
}
else
{
std::cout << "Also x is more (or equal) than " << y << '\n';
}
After
// One-line if
if (x<15)
y=30;
// Single if
if (x<5)
{
std::cout << "x is less than 5" << '\n';
}
// if with else
if (x<y)
{
std::cout << "Also x is less than " << y << '\n';
}
else
{
std::cout << "Also x is more (or equal) than " << y << '\n';
}
Remove
Before
if (x<5)
{
std::cout << "x is less than 5" << '\n';
}
After
if (x<y) {
std::cout << "Also x is less than " << y << '\n';
}
See also
- nl_else_brace - similar option but for else
- nl_if_leave_one_liners - if one-line if statements should be changed
- nl_multi_line_cond - Overrides nl_for_brace, nl_if_brace, nl_switch_brace and nl_catch_brace
- mod_full_brace_if - Add or remove braces on a single-line 'if' statement. Braces will not be removed if the braced statement contains an 'else'.