I want to know how I can automatically optimize imports after each save , how we do Eclipse (save actions).
IntelliJ IDEA offers the option Optimize imports on the fly in Settings | Editor | General | Auto Import and Optimize Import in the Commit Project dialog box.
Settings
Editor
General
Auto Import
Commit Project
The above answer works, but there is also an Intellij plugin "save actions" available from the JetBrains plugin repository that does this (like other things): Intellij Save Action Plugin .
Installation
File> Settings> Plugins> Browse repositories ...> Search "Save Actions"> "Code Tools"
Denial of responsibility
I am a plugin developer
First step:
CTRL + SHIFT + A or CMD + SHIFT + A (for mac)
Second step:
Search Import Optimization
Third step:
Enable option
In the 'Ultimate 2016.2' version, this is:
File> Other Settings> Default Settings> Auto Import> Optimize on-the-fly import