Whenever there is some missing or needs correction in code, visual studio code shows a yellow bulb to show some quick fixes suggestions.
Is there any way or shortcut by which we can navigate up and down suggestion options shown as in screenshot above without using the arrow keys?
In vscode v1.71 there are three new commands you can use for navigating in the QuickFix menu to go to previous or next source code actions.
selectNextCodeAction // to focus the nextcode action
selectPrevCodeAction // to focus the previous code action
acceptSelectedCodeAction // to run the focused/selected code action
You can see the default keybindings below that have been removed. Note the -
before the command name in two of the keybindings, that removes those keybindings.
You can make these keybindings (in your keybindings.json
):
{
"key": "alt+u", // whatever you want here
"command": "selectPrevCodeAction", // for v1.71
"when": "codeActionMenuVisible"
},
{
"key": "up", // default removed
"command": "-selectPrevCodeAction", // for v1.71
"when": "codeActionMenuVisible"
},
{
"key": "alt+d", // whatever you want here
"command": "selectNextCodeAction", // for v1.71
"when": "codeActionMenuVisible"
},
{
"key": "down", // default removed
"command": "-selectNextCodeAction", // for v1.71
"when": "codeActionMenuVisible"
}
The recent response by loann reminded me of Visual Studio Code Keybinding for navigation in Quick Fix contextual menu in which I mentioned the curious history of this context key, which went from CodeActionMenuVisible
to actionWidgetVisible
to codeActionMenuVisible
.
There is also an extension presented as a fix: Keyboard QuickFix, but it shouldn't be necessary anymore.