Search code examples
javaeclipsekey-bindingspowercommands

Format on save Eclipse


There was an add-on called Power Commands (Now productivity power tools) in visual studio to format the code on save.

I was so used to see my code format on save that I cannot change that habit. Is there a way to do that in Eclipse?

I can only assign one thing to Ctrl+S otherwise because if I assign Save & Format Code to the same keys, once I press the shortcut it will do neither but propose me what I want to do with the shortcut. Is there an add-on or a way to do it?


Solution

  • Go to

    Window > Preferences 
    

    then to

    Java > Editor > Save actions
    

    and tick Perform the selected actions on save, then tick Format source code

    You can also let eclipse perform Additional actions which you can freely configure.