views:

173

answers:

2

When I type the name of a class which will need to be imported, IntelliJ lovingly pops up with a list of suggestions. However, most of the time those suggestions are things I'd never want to import, especially by accident -- like java.awt.*.

Is there a way to prevent the packages I'll never import from appearing in the completion list?

I've scoured the options but I haven't found anything.

+2  A: 

Depending on the IDEA version: Yes.

In 7.0.5 use menu File -> Settings choose Code Completion and then Exclude from Import and Completion and add the package or class that you don't want to have in your suggestions.

In version 8 and version 9 use menu File -> Settings type "Auto import" into the search box and use the Exclude from Import and Completion box there.

In version 9 you also have the option of adding Classes and Packages to the exclude-list directly from the import suggestions context-menu:

alt text

Gerd Klima
Do we know why it disappeared in 8?
Benjamin Cox
Wonderful, thanks!
a paid nerd
@Benjamin C: well, I don't think it disappeared, I simply have no v8 on my machine so I couldn't describe the how-to. And JetBrains already moved the online help to v9...
Gerd Klima
+1  A: 

I'm not sure since when this feature exists. It certainly in the upcoming version 9.0:

When the import-popup shows you can navigate from there to two ignore-option. For example when you type List it could be 'ignore java.awt.List from auto-import' and 'ingore java.awt from auto import'

Or you can configure it in the settings: Editor->Auto-Import: There you can add and remove ignored packages and classes.

Gamlor
Unfortunately, I'm still stuck on v7. Thanks, though.
a paid nerd