This original answer was for Galileo which is well over a decade ago, so I'm updating it to be a little more current. Original answer remains below.
For Eclipse 2021-12 (under Window though I hope it would be the same across platforms):
- Go into
Project
, Properties
on the menu.
- Under
Java Code Style
, choose Formatter
.
- For the current project only, enable
project-specific settings
. For workspace settings, simply click on the Configure workspace settings
. Then click the edit
button.
- In the selection pane, under
Line Wrapping
, Wrapping settings
, Other expressions
, there is a Conditionals
item that you can edit.
The options you want are:
- wrap before operators;
- wrap where necessary;
- no force split; and
- indent on column.
They give this as an example:
This is the dated answer for Galileo:
- Go into
Project
, Properties
.
- Under
Java Code Style
, choose Formatter
.
- For the current project only, enable
project-specific settings
. For workspace settings, simply click on the Configure workspace settings
. Then click the edit
button.
- On the line-wrapping tab, choose
Expressions
, Conditionals
.
- Choose the relevant line wrapping policy and indentation policy.
I have "wrap only when necessary" and "indent on column" which appears to be close to what you want.
If you're not running Galileo, other versions of Eclipse should at least be close to that process. If my settings aren't quite what you want, you may need to fiddle with them a bit, but that Formatter
section is pretty well the entire exposed interface so, if it can't be done with that, it can't be done (short of writing your own plug-in or finding a more configurable third-party one).