Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to optimize imports automatically after each save in IntelliJ IDEA

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

like image 737
talha06 Avatar asked Jul 28 '12 20:07

talha06


People also ask

How do I clean up imports in IntelliJ?

CTRL + ALT + O ---> to remove the unused imports in windows. However, you can also change the keymap of "Optimize Imports" in settings.

How do I stop IntelliJ from optimizing imports?

4 Answers. Show activity on this post. Disable File | Settings | Editor | General | Auto Import | Optimize imports on the fly. Normally you don't need to add imports manually, IDEA does it for you.


2 Answers

IntelliJ IDEA offers an option to Optimize imports on the fly in Settings | Editor | General | Auto Import and Optimize imports option in the Commit Project dialog.

like image 155
CrazyCoder Avatar answered Sep 28 '22 01:09

CrazyCoder


The mentioned answer works, but there is also the Intellij "save actions" plugin available from the JetBrains plugin repository that does that (as well as other things): Intellij Save Actions Plugin.

Installation

File > Settings > Plugins > Browse repositories... > Search 'Save Actions' > Category 'Code tools'

Disclaimer

I'm the plugin developer

like image 23
Alexandre DuBreuil Avatar answered Sep 28 '22 01:09

Alexandre DuBreuil