Disable formatting in Eclipse

I found that when I save a .java file in Eclipse, it helps me to reformat any indentation and line breaks. This is very annoying. How can I avoid it?


This is part of "Code Clean up". You can configure what it does in Source -> "Clean Up ..."

Apart from that, you can also configure the formatter if you want the code formatted in general but don't like the defaults. To change these settings, use Window -> Preferences -> Java -> Code Style -> Formatter.

On the last tab of the formatter, you can define on/off tags which allow to you to prevent reformatting of some code.


You should be able to turn off formatting by placing a special comment, like

// @formatting:off
...
// @formatting:on

This can be changed in the preferences


You could disable you Save actions if you have any.

Go to Window > Preferences and follow Java > Editor > Save actions. Then uncheck the tick for Perform the selected actions on save.