Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse string literal line wrapping

Tags:

eclipse

When I run the Formatter it indents string literal lines all the way to the last line of the variable name, even if that exceeds the column guide, as shown in this screenshot:

Undesired line-wrapping behavior

Ideally, I want all of the lines to be wrapped similar to the way the first line is wrapped, with just a couple of tabs (or 1 tab if possible). I've changed all the Formatter settings for assignment and binary expression and it doesn't affect the Formatter's line wrapping behavior.

Is there a way to make Eclipse wrap lines like NetBeans or maybe with some plugin?

Here's what my Formatter settings are for Line Wrapping: enter image description here

like image 506
Michael Fulton Avatar asked Nov 08 '22 00:11

Michael Fulton


1 Answers

Plugins

  1. Eclipse Colorer

has an "Enhanced and fixed word wrapping mode".

  1. Eclipse Word-Wrap

is dedicated to word wrapping and might do the job.

Customization

Here's how and where you do it in Eclipse: Preferences->Java->Code Style->Formatter, then click the Edit button and select the Comments tab. After that, the same place, you can select the Line Wrapping tab and the Indentation tab. You can also set margins and tab sizes in Preferences>General>Editors>Text Editors by editing the Displayed Tab Width

I'll note that the Eclipse version should be Eclipse Project Neon (4.6) M4 or higher because Eclipse 4.6 came with some updated word wrapping out of the box.

like image 50
Wouter Vanherck Avatar answered Nov 15 '22 08:11

Wouter Vanherck