How to disable auto formatting upon save in Eclipse?

后端 未结 5 1088
南笙
南笙 2020-12-15 15:49

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.

相关标签:
5条回答
  • 2020-12-15 16:12

    Window > Preferences > Java > Editor > Save Actions.

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

    0 讨论(0)
  • 2020-12-15 16:17

    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

    0 讨论(0)
  • 2020-12-15 16:19

    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 :

    0 讨论(0)
  • 2020-12-15 16:20

    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

    0 讨论(0)
  • 2020-12-15 16:32

    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

    0 讨论(0)
提交回复
热议问题