Search code examples
javaeclipseformatspace

eclipse use available space line w


in our company we recently changed the used line width from like 80 to 150. Now it is quite annoying that all code is - of course - wrapped after 100 characters, as this was the previous setting.

We use save actions to run the format settings and it all works wonderful in the one direction: wrap too large lines.

But what I need now: UNWRAP me all lines as I now got enough space available, USE it. Is there a possibility to do that in form of a format setting? I couldn't find any

I now got this line (extremly) wrapped as there were not enough space:

    final List<SomeSuperDuperType> 
mySuperDuperListOfSuperDuperTypes = 
CrazyUtils.gimmeSomeCrazyStuffAsList(
parameter1, parameter2);

Now, with more space available, this code is still correctly formatted as it doesn't exceed the limit. Though I want to actually USE that extra space and make the line now like this (length=133):

final List<SomeSuperDuperType> mySuperDuperListOfSuperDuperTypes = CrazyUtils.gimmeSomeCrazyStuffAsList(parameter1, parameter2);

Solution

  • On Eclipse, go to Window>Preferences>Java>Code Style>Formatter, edit the active profile, and you'll find what you're looking for under the tab Line Wrapping.

    Then, select all your code (CTRL+A) and use CTRL+Shift+F to format the text using these new setttings.