views:

149

answers:

2

My code looks like this:

if (firstCondition() &&
        secondCondition()) {
    // ... code
}

The default settings for the code formatter in NetBeans wants to put the && on a new line, like this:

if (firstCondition()
        && secondCondition()) {
    // ... code
}

The formatter works well so I would just like to find the setting so it doesnt change the code to the latter. Whats the setting called?

A: 

Which version are u talking about, because my 6.7.1 definitely doesn't do that! It also doesn't have an option to do so.

Elijah
This is 6.8, but if that have changed it speaks for an option have been added. Which is good. Albeit with the "wrong" default value. Because as for you, it didnt do that for me before, and I always format my code. Which leads to a lot of unnecessary reformats.
mizipzor
+1  A: 

Tools > Options > Editor > Formatting
Language > Java
Category > Wrapping

There's no option for logical operators per se, but try the If Statement and Binary Operators and see how that works.

If that doesn't go far enough, you may want to check out JIndent.

Devon_C_Miller
Thank you, Ill check those next time I start NetBeans. But dedicated tools are always nice.
mizipzor
JIndent is also available as a plugin for NB.
Devon_C_Miller