In Eclipse, I can hit the Ctrl+Shift+O shortcut to auto import namespaces. How do I do it in IntelliJ IDEA Community Edition?
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.
The auto import for classes is working if you enable it under "Settings > Editor > General > Auto Import".
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.
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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With