Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse formatter line breaking assignments and method invocations

Tags:

eclipse

Is there a way I can configure eclipse to prefer breaking a long assignment by putting the '=' on a new line, and avoid breaking on a '.' character for a method invokation. I've noticed a bunch of settings like:

<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>

that can be added to an xml file that can be used to specify formatting, but I'm not sure which settings I should change to have the desired effect. Are these configurations documented somewhere (I tried Googling some relevant terms to no avail).

like image 581
jonderry Avatar asked Oct 23 '25 17:10

jonderry


1 Answers

The setting you're looking for regarding assignment line breaks is in:

Window (menu) > Preferences > Java > Code Style > Formatter
> Edit... (on active profile) > Line Wrapping (tab) > Expressions
> Assignments

where you can select your preferred line wrapping policy and indentation policy.

As for avoiding line breaks, still on the Line Wrapping tab, change the line wrapping policy on Function Calls > Qualified invocations to "Do not wrap".

In both cases, you can play with the preview width to see what effect the various policies will have on how your code is formatted.

like image 62
Amos M. Carpenter Avatar answered Oct 26 '25 10:10

Amos M. Carpenter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!