Turn off Eclipse formatter for selected code area? [duplicate]

To prevent specific portions of Java code from being formatted, go to “Window > Preferences > Java > Code Style > Formatter”. Click the “Edit…” button, go to the “Off/On Tags” tab and enable the tags. Afterwards, you can simply embed those tags in Java code to disable the formatting in-between them. If you don’t change the default tags, something like this will do :

//@formatter:off
this.
    portion.of(code
); // will not be touched by the formatter
//@formatter:on
but this will be
       reformatted.

IIRC, this option only exists since Eclipse 3.6.

As for css code, if you have installed Eclipse WTP, go to “Window > Preferences > Web > CSS Files > Editor” and you will find some basic formatting options there.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)