Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent Eclipse formatter from messing up text-bulleted comments?

I have (Java) comments such as:

/*   * The quick brown fox jumped over the lazy dog.  *  *  * Notes:  * - The quick brown fox jumped over the lazy dog. The quick brown fox  *   jumped over the lazy dog. The quick brown fox jumped over the lazy  *   dog.  * - The second quick brown fox jumped over the lazy dog. The quick brown  *   jumped over the lazy dog. The quick brown fox jumped over the lazy  *   dog.  */ 

The Eclipse auto-formatter sets the comment line width properly, but makes it:

/*  * The quick brown fox jumped over the lazy dog.  *   *   * Notes: - The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy  * dog. The quick brown fox jumped over the lazy dog. - The second quick brown fox jumped over the  * lazy dog. The quick brown jumped over the lazy dog. The quick brown fox jumped over the lazy dog.  */ 

How do I the code formatter to leave the bulleted lists as-is, while still otherwise processing the comment?

Notes:

  • I don't want to turn off line joining in comments, because I do want my comment lines to be fit to the maximum length. So turning off line joining, or turning off formatting for Javadoc comments, or temporarily suspending autoformatting, are not acceptable solutions.
  • Possibly related question.
like image 554
einpoklum Avatar asked Sep 25 '12 07:09

einpoklum


People also ask

How do I turn off auto format in Eclipse?

To change these settings, use Window -> Preferences -> Java -> Code Style -> Formatter.

How do I change the comment style in eclipse?

Eclipse: Change the block comment style of ctrl+shift+/

What is the code for beautify in eclipse?

Go to Source | Format Document or press Ctrl+Shift+F.


1 Answers

This answer says that you add a hypen right after the opening /*, i.e.:

/*-   * The quick brown fox jumped over the lazy dog.  *  *  * Notes:  * - The quick brown fox jumped over the lazy dog. The quick brown fox  *   jumped over the lazy dog. The quick brown fox jumped over the lazy  *   dog.  * - The second quick brown fox jumped over the lazy dog. The quick brown  *   jumped over the lazy dog. The quick brown fox jumped over the lazy  *   dog.  */ 

This worked for me too.

like image 96
Varun Achar Avatar answered Sep 17 '22 17:09

Varun Achar