Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limiting IntelliJ IDEA import suggestions on completion

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.

like image 829
a paid nerd Avatar asked Nov 12 '09 22:11

a paid nerd


People also ask

How do I stop IntelliJ from optimizing imports?

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. While this the common case in Java, with Scala and implicit conversions, things are not as smooth.

How do I turn off suggestions in IntelliJ?

Start typing. By default, IntelliJ IDEA displays the code completion popup automatically as you type. If automatic completion is disabled, press Ctrl+Shift+Space or choose Code | Code Completion | Type-Matching from the main menu. If necessary, press Ctrl+Shift+Space once again.

How do I optimize imports in IntelliJ?

To optimize imports in a file, you can also press Ctrl+Alt+Shift+L , select Optimize imports, and click Run.


1 Answers

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

like image 199
Gerd Klima Avatar answered Sep 24 '22 19:09

Gerd Klima