How to Stop Eclipse from Auto-Formatting Comments
Tags:

Eclipse's ability to automaticlly format code is a great way to have clean, uniform looking code in your projects. However, there are probably some places that you'd rather Eclipse not touch. A good example of this is commented-out SQL code. SQL and Java code are typically formatted very differently, so running the auto-formatter (Ctrl + Shift + F on Windows) will mangle SQL code. Compare SQL formatted by hand to the same code after running the formatter:

SQL before formatting

SQL after formatting

If you are using multi-line comments (/* */), the fix to prevent Eclipse from applying its auto-formatting is very simple: just add a dash (-) after the asterisk at the beginning of the comment (see below).

The dash on line 148 prevents auto-formatting