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.
I think I found the answer for my own question.
Project-> Preferences->Java Editor-> Save Action- >uncheck Format source code
This will disable all the source code format.
There are some answers saying that
Project ->Preferences->Java Code style-> Formatter (disable) or Project ->Preferences->Java Code style-> Clean up (disable)
Both both are only the setting that tell how the code be formatted It will still format the source code even if you uncheck the Formatter and Clean UP but check the Editor Save action
Java Editor will override all the source code settings.
There is another solution that you can use to suppress the formatting of specific block comments. Use /*- (note the hyphen) at the beginning of the block comment, and the formatting won't be affected if you format the rest of the file.
/*- * Here is a block comment with some very special * formatting that I want indent(1) to ignore. * * one * two * three */