How to optimize import automatically after each save in IntelliJ IDEA

I want to know how I can automatically optimize imports after each save , how we do Eclipse (save actions).

+82
intellij-idea ide
Jul 28 '12 at 20:15
source share
4 answers

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.

+125
Jul 28 2018-12-12T00:
source share

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

+50
Dec 30 '15 at 13:22
source share

First step:

 CTRL + SHIFT + A or CMD + SHIFT + A (for mac) 

Second step:

Search Import Optimization

Third step:

Enable option

enter image description here

+10
Nov 19 '17 at 6:14
source share

In the 'Ultimate 2016.2' version, this is:

File> Other Settings> Default Settings> Auto Import> Optimize on-the-fly import

+5
Oct 26 '16 at 23:28
source share



All Articles