Skip to content

Code Actions

Jens Fischer edited this page Apr 20, 2019 · 23 revisions

When a Code Action is available for the current selection / cursor position, this is indicated by a light bulb to the left of the editor:

To show the available actions, either click the light bulb or press Ctrl+.. This will open a popup menu:

In case you want to change the default shortcut, the command for this keybinding is "editor.action.quickFix".

Additionally, there's also an "Auto Fix" command ("editor.action.autoFix") that directly applies the "preferred" code action if one exists (usually the first one), without opening a menu. The default shortcut is Shift+Alt+..

Here is an overview over all Code Actions that currently exist:


Add import

Change to fully qualified type

Unused Code

Remove unused import/using

Remove all unused imports/usings

Remove unused variable

Compiler Errors

In some cases, simple compiler errors can be fixed with a Code Action:

Invalid package

Typo suggestions

Missing override keyword


  • "editor.codeActionsOnSave" - Code Actions to be applied when the file is saved. This can be used to trigger the Remove all unused imports/usings code action on save:

     "editor.codeActionsOnSave": {
     	"source.organizeImports": true
You can’t perform that action at this time.