Java formatting: Indentation of conditions inside if (...)
I have code like this:
if (a = b && c == d
&& (e == f
|| g == h)
|| i == j) {
k = l;
}
while (a = b && c == d
&& (e == f
|| g == h)
|| i == j) {
k = l;
}
I haven't been able to find settings that make the code formatting indent the code as above.
If I enabled Wrapping & Braces -> Binary Expressions -> Align Parenthesized when multiline, the result is
if (a = b && c == d
&& (e == f
|| g == h)
|| i == j) {
k = l;
}
while (a = b && c == d
&& (e == f
|| g == h)
|| i == j) {
k = l;
}
This is close but the line with g == h gets indented 12 spaces instead of 8. Somehow seems that IDEA combines indentations settings a bit too much here.
If I enabled Wrapping & Braces -> Binary Expressions -> Align when multiline, the result is
if (a = b && c == d
&& (e == f
|| g == h)
|| i == j) {
k = l;
}
while (a = b && c == d
&& (e == f
|| g == h)
|| i == j) {
k = l;
}
Tabs & Indents -> Use indents relative to expressions start also makes different indentation with if & while because start of expression is actually the opening parenthesis.
I want continuation expression on row with e == f to be intended 8 and the g == h continuation to be indented 8 spaces more.
Any ideas?
请先登录再写评论。
Anyone?
You know that Eclipse can do this and apparently Idea cannot?
If's and while's do not have 'align when multiline' which is my curse too.