views:

156

answers:

1

My apologies if I'm missing something obvious but there's something that really bugs me about the Eclipse code formatter. I don't want it to make any lines of code longer, only shorter. Is there a way to force the formatter to behavior this way?

Example 1:

if (somethingIsTrue() || somethingElseIsTrue()) {
  //-- Do Something.
}

Example 2:

if (somethingIsTrue() ||
    somethingElseIsTrue()) {
  //-- Do something.
}

I don't want the formatter to touch either of these code blocks. Currently it will always expand the second example to match the first. I don't want that.

Any ideas?

+5  A: 

If this is Java, under Preferences.Java.Code Style.Formatter and then in tab Line Wrapping there is a check box called Never join lines. That's worth a try...

DigitalRoss
It's new in Eclipse 3.5, and requires you also fine tune exactly when you break lines.
Stephen Denne
I was hoping for something a little less tedious. Also, we're still stuck with 3.3 where I work. So unfortunately this won't work for me. Good to know there's at least an option when we upgrade though.
lycono