Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative or way to force eclipse source code formatter to break line at 80 characters?

Whenever I use the Eclipse source code formatter / beautifier (via the menu item Source - Clean Up or CTRL - SHIFT - f) it reformats statements that I have broken into multiple lines back into one line that is longer than 80 chars, eg I have:

public CDataCacheContainer loadDataset(CDataFileDef dsd) 
   throws IOException {

and it becomes

public CDataCacheContainer loadDataset(CDataFileDef dsd) throws IOException {

which is longer than 80 characters and looks poor when printed.

Can I prevent eclipse from doing this? Or is there an alternative eclipse source code formatter that wraps at 80 characters nicely?

EDIT 1: In Eclipse under Window - Preferences - Java - Code Style - Formatter - Edit the maximum line width was set at 80. I've changed it to 78 and also enabled wrapping on Assignment expressions and this has helped. Now the only expression that isn't wrapping is this one:

datasetsNode.add(new TreeUtil.PanelViewNode(this, table)); // NOPMD

and others like it.

like image 335
tekumara Avatar asked Oct 28 '09 01:10

tekumara


1 Answers

From menu bar: Window > Preferences > Java > Code Style > Formatter > Edit (button) > Line Wrapping (tab). You can customize the maximum line width and change the line wrapping policy.

like image 148
Dean Povey Avatar answered Sep 27 '22 16:09

Dean Povey