Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How configure optimize imports on the fly without rearrange import statements?

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?

like image 777
Cherry Avatar asked Sep 26 '13 11:09

Cherry


People also ask

How do you optimize imports?

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

How do I stop IntelliJ from changing imports?

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.

How do I change the import order in IntelliJ?

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.


1 Answers

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.

like image 171
ford Avatar answered Oct 28 '22 14:10

ford