Remove unused import in Reformat Code in android studio

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.


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"


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.