I want imports to be deleted immediately after they become unused, so I checked Editor | General | Auto Import | Optimize imports on the fly
, but it doesn't work.
To optimize imports in a file, you can also press Ctrl+Alt+Shift+L , select Optimize imports, and click Run.
Optimize imports The Optimize Imports feature helps you remove unused imports and organize import statements in the current file or in all files in a directory at once according to the rules specified in Settings/Preferences | Editor | Code Style | <language> | 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.
If Optimize imports on the fly
is selected as you have done, then unused imports should definitely be removed automatically, given that:
Source Route
.and
To optimize imports in many files at once, you can use ctrl+alt+O, or you can also tick Optimize Imports option when you check in files to source control (for example svn
).
Please make sure that under Java | Imports
, the Unused import (editor light)
inspection is enabled.
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