Is there a way to make Eclipse\'s built-in Java code formatter ignore comments? Whenever I run it, it turns this:
/*
* PSEUDOCODE
* Read in us
I just learned from a co-worker that Eclipse offers special formatting tags that can be used for this:
// @formatter:off
/*
* ╔════════╦═══════╦══════════╗
* ║ Month ║ Sales ║ Position ║
* ╠════════╬═══════╬══════════╣
* ║ June ║ 44k ║ 2nd ║
* ║ July ║ 39k ║ 2nd ║
* ║ August ║ 49k ║ 4th ║
* ╚════════╩═══════╩══════════╝
*
* This comment shouldn't be formatted, and will now be ignored by the formatter.
*/
// @formatter:on
Note that you may need to manually enable this feature through the Preferences menu → Java > Code Style > Formatter, clicking on Edit, selecting the Off/On Tags tab and checking Enable Off/On tags (source).
A quick Google for the string @formatter:off brought me to this other SO answer, which mentioned this feature in the context of disabling the formatter for code blocks. I've confirmed that it works for line comments, "normal" block comments and Javadoc block comments as well.