I haven't been successful in figuring out how to wrap each method call in Eclipse
. For example, I have this:
someObject.A().B().C();
But I really want this:
someObject.A()
.B()
.C();
Nothing under the "Line Wrapping" section in Eclipse
seems to give me this result.
Customize your eclipse formatter in both java and javascript. increase the max line with that fits your screen.
Complementing Deepak Azad's answer, what you exactly need is the following:
Then, in the list at the left, select:
Now below this list, set Line wrapping policy to:
Check:
Finally, set Indentation policy to (thanks @Turbo):
It should give you the exact behavior you asked for.
BONUS: Android Studio / IntelliJ Idea:
select
and check
For those who have eclipse code formatting settings checked into source control (for consistent code formatting across the whole team), the
.settings
folder is checked in.The property that will give you this formatting behavior is in the
.settings/org.eclipse.jdt.core.prefs
file.The property is:
If you are willing to do the formatting of those segments yourself, you can prevent eclipse from reformatting those segments by using:
You might need to enable this in your preferences: http://archive.eclipse.org/eclipse/downloads/drops/R-3.6-201006080911/eclipse-news-part2.html#JavaFormatter
See also: How to turn off the Eclipse code formatter for certain sections of Java code?
Window->Preferences->Java->Code Style->Formater->Edit->Line wrapping->Never join already wrapped lines
in: Window->Preferences->Java->Code Style->Formater->Edit->Line wrapping->Function call-> Qualified invocation
select Indentation policy as indent on column