How to remove unused imports in Intellij IDEA on commit?

Leonid picture Leonid · Sep 25, 2012 · Viewed 124.1k times · Source

Is there a way to remove unused imports in Intellij IDEA on commit?

It is not very optimal to do it manually, CTRL + ALT + O helps but it's still manual.

Answer

Madan Sapkota picture Madan Sapkota · Jun 4, 2015

If you are using IntelliJ IDEA or Android Studio:

Android optimize imports

Go to Settings > Editor > General >Auto Import and check the Optimize imports on the fly checkbox.