Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop Eclipse from mangling my comments

Is there a way to stop eclipse from mangling the comments in my source files?

My main issue is stopping it from word wrapping them. I've managed to configure eclipse to not word wrap any code but it still seems to do it to comments.

Code that I enter like this:

public int myVariable = 100; // this variable is a very interesting variable and it does lots of stuff 

End up like this:

public int myVariable = 100; // this variable                              // is a very                              // interesting                              // variable and                              // it does lots                              // of stuff 
like image 208
Omar Kooheji Avatar asked Oct 19 '09 11:10

Omar Kooheji


2 Answers

There is another solution that you can use to suppress the formatting of specific block comments. Use /*- (note the hyphen) at the beginning of the block comment, and the formatting won't be affected if you format the rest of the file.

 /*-  * Here is a block comment with some very special  * formatting that I want indent(1) to ignore.  *  *    one  *        two  *            three  */ 

Source: http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-141999.html#680

like image 173
Michelle Crane Avatar answered Sep 23 '22 08:09

Michelle Crane


Go to the "Window" menu -> preferences
choose the editor you're interested in from the list on the left.(e.g. Java)
then there should be a subsection called "Code Style", and under that "Formatter".

Then you'll need to create a new formatter profile. (The built-in profile can't be edited) On the last tab of the profile configuration is options for comment formatting

like image 24
Jonathan Fingland Avatar answered Sep 22 '22 08:09

Jonathan Fingland