How to add 'Remove unused imports' shortcut to Visual Studio Code
- Install PyLance (VSCode extension)
- Add the following to your
keybindings.json
(Ctrl-Shit-P -> “Preferences: Open Keyboard Shortcuts (JSON)”):
,{
"key": "shift+alt+r",
"command": "editor.action.codeAction",
"args": {
"kind": "source.unusedImports",
}
}
- Save, and you’re ready to go