How to enable "remove unused imports"


I don't see it under Settings | Code | Imports..

I'm using 10.5.1


Preferences->Editor->Auto Import->Optimize Imports on the Fly will automatically remove unuxed imports.


For anyone looking for this ten years later, the option has moved slightly to:

Preferences->Editor->General->Auto Import->Optimize Imports on the Fly


On Fri, 23 Sep 2011 19:42:34 MSD, Stephen Boesch
<> wrote, quoted or indirectly quoted someone
who said :

>I don't see it under Settings | Code | Imports.

I prefer to it manually, as part of reformat code.

If it tidies code which in a chaotic state, e.g. you have just pasted
in a mess of code from elsewhere, you often find that it tosses out
all kinds of GOOD imports.  You then have to tediously recreate them.

I don't tidy until I have a clean compile.
Roedy Green Canadian Mind Products
It should not be considered an error when the user starts something
already started or stops something already stopped. This applies
to browsers, services, editors... It is inexcusable to
punish the user by requiring some elaborate sequence to atone,
e.g. open the task editor, find and kill some processes.


thx that's what I was looking for


Thanks Thomas Kelley, I've enabled the optimize imports but turns out I also have to enable it on General


Is there any way to just remove the unused imports instead of completely moving them around? It is a nightmare when people use different IDEs that "optimize" their imports in the way they feel like it is a good idea. I've seen commits that are literally just imports being moved around by the IDE or the guy who uses Eclipse removing the `.*` and the guy who uses IntelliJ bringing them back and then conflicts happen on these imports


Guilherme Taffarel Bergamin

You can remove all of the rules specified in Settings/Preferences | Editor | Code Style | <language> | Imports. Then hitting Ctrl+Alt+O (on Windows) will just remove unused imports, no moving them around.

E.g. for Java, see


Please sign in to leave a comment.