Reputation: 2656
I know Ctrl+Shift+O
shortcut key for remove unused import but is possible to remove unused import in reformat code in android studio.
Edit 1:
What i am looking for : A option for remove unused import when reformat code.reformat code option usually find in Preferences->Editor->Code Style->Java
Upvotes: 25
Views: 19342
Reputation: 5317
For Mac use ⌃ + ⌥ + O
For Windows use Ctrl + Alt + O
Chill Pill :)
Upvotes: 2
Reputation: 14173
Open reformat file dialog (ctrl+shift+alt+L
), there is an option there "Optimize import", select it and press run
. Now whenever you reformat code (ctrl+alt+L
) it will also optimize imports.
Upvotes: 68
Reputation: 51
The "Optimize imports" option is in the "Reformat File Dialog". You could find the shortcuts in Preferences->Keymap with key word "Show Reformat File Dialog"
Upvotes: 3
Reputation: 628
In android studio Ctrl+Shift+O
does not remove unused imports it is used in Eclipse, here we can use Ctrl+Alt+O
to remove unused imports and Ctrl+Alt+l
to format code.
Upvotes: 9