Optimizing Imports
Optimize imports in the project
-
Place the caret at the Project tool window and do one of the following:
On the main menu, choose
.Press Ctrl+Alt+O.
The Optimize Imports dialog box opens.
If your project is under version control, the option Only VCS changed files is enabled. Select or clear this option as required.
Click Run.
One way of dealing with unused import is to use the quick-fix that appears when you set the caret at the highlighted unused import. However, you can optimize imports in a larger scope as described below.
Optimize imports in the current file
On the main menu, choose
.Press Ctrl+Alt+O.
Place the caret at the import statements, click , and choose Remove unused import.
Open the Reformat File Dialog Ctrl+Shift+Alt+L and select the Optimize imports checkbox.