Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse auto-formatter, disable auto line-wrapping of comment lines

I love eclipse auto formatting, but there's one feature that's driving me raging mad:

Since I use wrap-lines in my auto-formmatter, code like this:

private static Location                         _location           = null; // this is a comment 

turns into horrible, horrible code like this:

private static Location                         _location           = null;                 // this                                                                                                     // is                                                                                                     // a                                                                                                     // comment 

this is not only painful to watch, but not at all convenient to change back...

Is there any way to remove line-wrapping for comments, or at least fix so it doesn't look like an absolute mess?

Thanks

like image 981
Gal Avatar asked Mar 10 '12 09:03

Gal


People also ask

How do I turn off auto format in Eclipse?

For this got to Window->Preferences> Java -> Editor->Save Actions-> click on "Configure project specific Settings ". On the bottom of the window select the check box "Show only project with project specific settings " . Then select a module/project -> Ok-> Un check "Enable project specific settings"--> Apply.

How do you line wrap in eclipse?

There is a "Toggle Word Wrap" command hidden in the "Window > Editor" menu (default shortcut is Alt+Shift+Y). Or you can use the Quick Access bar: Ctrl+3, and type wrap.


1 Answers

I think that the thing you are specifically asking about you can achieve by editing your formatter:

  • Window -> Preferences -> Java -> Code Style -> Formatter. There edit you click on Edit...
  • If you are using the default Eclipse formatter you will need to edit the profile name (you cna not edit built in profile).
  • Go to comments
  • Deselect line comment formatting.

That way no formatting of comments of the type // will be done.

like image 170
Boris Strandjev Avatar answered Sep 22 '22 12:09

Boris Strandjev