Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open the lightbulb via shortcut?

Some languages support code actions which display a lightbulb providing quick fixes for a warning/error (See https://code.visualstudio.com/docs/editor/editingevolved#_code-action for more information). I like this feature but I don't like to click on the lightbulb. Unfortunately I can't find a shortcut for opening the lightbulb at the current cursor position. How can I create such a shortcut?

I tried to create a shortcut for vscode.executeCodeActionProvider by creating a custom keybinding like this:

[{ "key": "alt+enter", "command": "vscode.executeCodeActionProvider"}] 

But everytime I hit the shortcut I receive the warning

Running the contributed command:'vscode.executeCodeActionProvider' failed.

like image 619
Wosi Avatar asked Dec 01 '15 12:12

Wosi


People also ask

What does the lightbulb mean in VS code?

The yellow light bulb icon indicates there are actions available that you should do to improve your code. The error light bulb. icon indicates there's an action available that fixes an error in your code.

How do I show potential fix in Visual Studio?

You can change that keyboard shortcut. As an example use " Ctrl + Enter " Instead of " Ctrl + . " for C# Quick Actions on Visual Studio. Now you can use " Ctrl + Enter " to show 'potential fixes' and select one.


1 Answers

The correct command editor.action.quickFix. The default binding on Windows looks like this:

{ "key": "ctrl+.", "command": "editor.action.quickFix",                    "when": "editorTextFocus" } 

On Mac it's CMD + ..

like image 144
Wosi Avatar answered Sep 19 '22 21:09

Wosi