In intellij Idea it is possible to configure imports optimization on the fly, if this configuration set, IDE will delete unused imports and sort them. But is it possible to enable import optimization on the fly but without sorting imports? For example I do not want to highlight unnecessary changing in code review system, that mark rearranged import statements as changes code lines. So is it possible to optimization imports without sorting?
To optimize imports in a file, you can also press Ctrl+Alt+Shift+L , select Optimize imports, and click Run.
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.
Open the 'Settings' (or 'Preferences' in mac) window and goto Editor > Code Style > Java. Click on 'Imports' tab. In 'Import Layout' area, you can arrange the import order by selecting the import type and clicking on the arrow (see image below). Once the changes are done apply the new settings.
The "Optimize imports on the fly" option doesn't have a "rearrange entries" option to turn off. The Settings dialog has some configuration under Code Style -> Java -> Imports tab that might be helpful (the optimizer will be using this configuration). At the very least, you can probably reduce the amount of optimization done by playing with those settings.
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