Save actions in IntelliJ IDEA

You will need to Install Save Actions plugin for Intellij IDEA

  1. Click: ctrl+shift+a
  2. Type: Plugins
  3. Click: enter Plugins
  4. Click: Browse repositories
  5. Type: Save Actions to search field
  6. Click "install plugin" after you found it
  7. Restart intellij idea

Save actions now work. You can configure them in File -> Settings -> Other settings


UPDATE: Since IntelliJ Version 2021.2 Jetbrains added support for Actions on Save. They can be found under Preferences/Settings | Tools | Actions on Save.

Source: https://blog.jetbrains.com/idea/2021/07/intellij-idea-2021-2/#key_updates


It doesn't exist as in Eclipse, but you can format your code on commit, and the shortcut ctrl+alt+L will allow you to format easily your code.
After a time formatting the code will be a reflex and you won't even think about it.


On the same topic :

  • Intellij reformat on file save

You may use a Macro to simulate save actions:

Edit --> Macros --> Start Macro Recording

==> now execute all actions you need (e.g. reformat, rearrange, optimize imports)

Edit --> Macros --> Stop Macro Recording

Give your new Macro a name. You can also assign a shortcut to your macro. Just enter it's name in the settings search and you will find it under Macro.

Have fun!