Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ Idea 12: How do I auto import namespaces?

In Eclipse, I can hit the Ctrl+Shift+O shortcut to auto import namespaces. How do I do it in IntelliJ IDEA Community Edition?

like image 414
NoobDeveloper Avatar asked Dec 25 '12 17:12

NoobDeveloper


People also ask

How do I automatically import imports in IntelliJ?

Automatically add import statements You can configure the IDE to automatically add import statements if there are no options to choose from. In the Settings/Preferences dialog ( Ctrl+Alt+S ), click Editor | General | Auto Import. Select the Add unambiguous imports on the fly checkbox, and apply the changes.

How do I automatically import classes in IntelliJ?

The auto import for classes is working if you enable it under "Settings > Editor > General > Auto Import".

How do I change import settings in IntelliJ?

The solution is to go to Preferences ( ⌘ + , on macOS / Ctrl + Alt + S on Windows and Linux) > Editor > Code Style > Java > Imports tab set Class count to use import with '*' and Names count to use static import with '*' to a higher value. Any value over 99 seems to work fine.

Do not use * imports IntelliJ?

To avoid IntelliJ IDEA replacing imports with * , you need to configure the Class count to use import with '*' and Names count to use static import with '*' preferences: Go to Preferences > Editor > Code Style > Java.


1 Answers

Code > Optimize Imports will provide you the behavior you are after. If you want to adjust the settings you can so via Settings > Editor > Auto Import.

enter image description here

like image 75
Aaron McIver Avatar answered Oct 21 '22 07:10

Aaron McIver