Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse: Set maximum line length for auto formatting?

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?

like image 270
Nick Heiner Avatar asked Sep 13 '10 00:09

Nick Heiner


People also ask

How do I limit a line length in Eclipse?

To set the maximum line length in Eclipse, open Eclipse and in the menu bar, go to Window -> Preferences and in the pop-up window, go to Java -> Code Style -> Formatter. This will open up the Formatter options in the right window pane. Click on the Edit button to modify the current formatter profile.

How do I set column limits in Eclipse?

(2/2) Go to:Window --> Preferences --> C/C++ [or whatever language you are using] --> Code Style --> Formatter --> click Edit --> under the Line Wrapping tab set the value you desire for Maximum line width .

How do I fix the length of a line in Java?

1) How to change the line length for auto formatting of java code (while using Ctrl+Shift+F)? Go to tab Line wrapping. Default value for Maximum line length is 120. Set Maximum line width to some higher number as per your requirement, I have set it to 140.


1 Answers

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.

like image 175
John Percival Hackworth Avatar answered Oct 01 '22 12:10

John Percival Hackworth