How to delete all unused imports at once?.

Answered

I find myself often deleting unused imports manually, you know, the ones grayed out, at least in the Darcula theme.

Is there any command to delete them all at once?.

0
4 comments

Help | Find Action (remember its shhortcut BTW!) and type 'Optimize imports'. The action will be found for you - remember its shortcut as well!
Other action is 'Reformat Code' - it can both optimize imports an fix formatting for the whole file.

6
Avatar
Permanently deleted user

Thanks, worked perfectly.

0
Avatar
Permanently deleted user

You could use `control + option + O` form make

0
  • Select menu "Code > Inspect Code"
  • In the Inspections panel that will open, navigate to "Warning > Java > Imports > Unused import"
  • Select all items
  • Select "Delete unnecessary import" in the right-click menu.
3

Please sign in to leave a comment.