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
As of Visual Studio Code Release 1.22 this comes free without the need of an extension. Shift + Alt + O will take care of you.
Adding or removing an import from multiple files isort can be ran or configured to add / remove imports automatically.
In Android Studio, there is a way to automatically organize imports as you type. If you are on a Mac, go to Android Studio -> Preferences (on Windows I think it's under File -> Settings), and then under Editor -> Auto Import, you can change the settings to look like this.
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.
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.
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"
For Mac use ⌃ + ⌥ + O
For Windows use Ctrl + Alt + O
Chill Pill :)
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