How to disable auto formatting upon save in Eclips

2020-02-26 02:36发布

Eclipse keeps auto formatting upon save, for example: it is insisting the following code should be in a single line once I save, despite breaking it up the way I want to.

@Transactional(rollbackFor = DataAccessException.class, readOnly = false, timeout = 30, propagation = Propagation.SUPPORTS, isolation = Isolation.DEFAULT)

5条回答
Summer. ? 凉城
2楼-- · 2020-02-26 03:20

Window > Preferences > Java > Editor > Save Actions.

Can also be configured at the project level. Project > Properties > Java Editor > Save Actions.

查看更多
成全新的幸福
3楼-- · 2020-02-26 03:26

This is a Late answer, But just for novice to understand it clearly I have a snapshot of the setting. Please follow the path on left.
And change highlighted setting. enter image description here

查看更多
Ridiculous、
4楼-- · 2020-02-26 03:27

Just wanted to add a tip. If you want to avoid the line wrapping you can simply increase the "Maximum line width" value to something enormous. As long as that is sufficiently high eclipse won't do any wrapping.

Preferences > Java > Code Style > Formatter > Edit > Line Wrapping > Maximum line width

查看更多
Root(大扎)
5楼-- · 2020-02-26 03:28

Absolutely maddening improvement. For if statements do the following: Window | Preferences | Java | Code Style | Formatter | Control statements tab Select Keep simple if on one line. You might also try the Line wrapping tab

查看更多
Anthone
6楼-- · 2020-02-26 03:37

If you wish to keep the auto-formatter, but don't want this behavior, you can also configure it in the fomatter :

right click on the project -> properties -> java code style -> formatter

(If you don't have a project specific formatter the global configuration can be accessed this way : Window -> Preference -> Java -> Code Style -> Formatter).

Edit... the active profile, open the Line Wrapping tab, and there check the Never join already wrapped lines option.

This way you can wrap lines wherever you want and eclipse won't remove your line breaks (which is a must if you wish to have readable lambda expressions), but keep the formatter active.

This option is there at least since eclipse Luna

Here is a screenshot where this option is : enter image description here

查看更多
登录 后发表回答