Eclipse: Set maximum line length for auto formatting?

JavaEclipseFormattingIde

Java Problem Overview


I am working with Java. If I hit Ctrl+Shift+F in Eclipse Helios, it will auto format my code. At a certain point, it wraps lines. I would like to increase the maximum line length. How can I do this?

Java Solutions


Solution 1 - Java

In preferences Java -> Code Style -> Formatter, edit the profile. Under the Line Wrapping tab is the primary option for line width (Maximum line width:). In the Comments tab you have a separate option Maximum line width for comments:, which will also need to be changed to affect comment wrapping.

You will need to make your own profile to make these changes in if you using one of the [Built-in] ones. Just click "New..." on the formatter preferences page.

Solution 2 - Java

Take a look of following image:

Java->Code style->Formatter-> Edit

enter image description here

Solution 3 - Java

Comments have their own line length setting at the bottom of the setting page java->code style->formatter-> Edit... ->comments

Solution 4 - Java

for XML line width, update preferences > XML > XML Files > Editor > Line width

Solution 5 - Java

For HTML / PHP / JSP / JSPF: Web -> HTML Files -> Editor -> Line width

Solution 6 - Java

Click Project->preferences. Type format into the search - you should see java->code style->formatter. Click that, then edit - finally, the line wrapping tab - its there :)

Solution 7 - Java

For XHTML files: Web -> HTML Files -> Editor -> Line width

Solution 8 - Java

Preferences -> Java -> Code Style -> Formatter / "Edit..."

Tabs: "Line wrapping" , "Comments"

Field: "Maximum line width"

Set both to make comments have the same length too. You might need to create a new profile if you don't have one already.

Solution 9 - Java

I use the Eclipse version called Mars which works with Java 7.

Go to Preferences -> Java -> Code Style -> Formatter

Click on the Edit Button shown in the right side of "Active Profile" drop down

Tabs: "Line wrapping"

Field: "Maximum line width", Set the desired value (Default value set to 120) to increase/decrease the line length in the editor

Note: Remember to rename the Active profile to the name of your choice, as the default Eclipse profile won't accept your changes.

Solution 10 - Java

Line length formatter setup is blocked for annotations (Eclipse Photon checked). Therefore it is needed in Line Wrapping -> Wrapping settings -> Annotations. Setup line wrapping as appropriate for you. There is couple of possibilities, e.q. Enable wrap when necessary to use first icon list.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNick HeinerView Question on Stackoverflow
Solution 1 - JavaJohn Percival HackworthView Answer on Stackoverflow
Solution 2 - JavaSumit SinghView Answer on Stackoverflow
Solution 3 - JavaboukahView Answer on Stackoverflow
Solution 4 - JavaAmir AradView Answer on Stackoverflow
Solution 5 - JavafbtbView Answer on Stackoverflow
Solution 6 - JavaChozabuView Answer on Stackoverflow
Solution 7 - JavaPhantomReferenceView Answer on Stackoverflow
Solution 8 - JavaRooView Answer on Stackoverflow
Solution 9 - JavamannedearView Answer on Stackoverflow
Solution 10 - JavahariprasadView Answer on Stackoverflow