vscode: Missing keybinding for navigation in Quick Fix contextual menu

The problem:

It is not possible to define custom shortcuts for Quick Fix contextual menu.

  • Use latest stable build of VS code and open a TypeScript project.
  • Open the Quick Fix by intentionally making a mistake in the code.
  • Press CTRL + . to open the Quick Fix contextual menu suggestions.
  • It is possible to select an item from the menu by using UP/DOWN arrow key.
  • ISSUE: it is no possible to define custom shortcuts in order to select the prev/next Quick Fix suggestion in the contextual menu. Would be great to have customize selection of the prev/next suggestion, similarly to IntelliSense (example below):
    {
      "key": "ctrl+k",
      "command": "selectPrevSuggestion",
      "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    },
    {
      "key": "ctrl+j",
      "command": "selectNextSuggestion",
      "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    },

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 138
  • Comments: 30 (3 by maintainers)

Most upvoted comments

Please prioritize. The lack of custom binding is a productivity killer for vim-like users. The workflow is interrupted each time you have to reach for the arrow keys. And some linux-centric keyboards don’t even have the arrow keys. They would have to press combo keys to get the arrow keypress event.

I created a extension as a workaround: https://marketplace.visualstudio.com/items?itemName=pascalsenn.keyboard-quickfix

It uses the quick open picker to display codeactions. It is possible to navigate through these with the keyboard

(see below comment for updated keybindings id/criteria)

With the new Code Action Widget (which applies to the refactoring and source controls from the context menu, the lightbulb widget, and quickfixes), custom keybindings for navigation, selection, and previews have been added.

Currently the widget is under an experimental setting "editor.experimental.useCustomCodeActionMenu": true. Can also be found by going to Editor › Experimental: Use Custom Code Action Menu!

Take a look at this snippet for keybindings.json

[
  {
    "key": "ctrl+k",
    "when": "CodeActionMenuVisible",
    "command": "focusPreviousCodeAction"
  },
  {
    "key": "ctrl+j",
    "when": "CodeActionMenuVisible",
    "command": "focusNextCodeAction"
  }
]

Couple modifications in the latest update! As @MejanH mentioned, the commands are changed into selectNextCodeAction and selectPrevCodeAction in the new update.

A problem that @d-khomenko brought up is resolved with changing CodeActionMenuVisible to camel-case - codeActionMenuVisible

[
  {
    "key": "ctrl+k",
    "when": "codeActionMenuVisible",
    "command": "selectPrevCodeAction"
  },
  {
    "key": "ctrl+j",
    "when": "codeActionMenuVisible",
    "command": "selectNextCodeAction"
  }
]

So sad, can’t use shortcut to move in Quick Fix contextual menu break my coding experience. can you fix this bug quickly?

Currently as a work around I use the following key biding in keybindings.json, I hope you find it useful.

[
  {
    "key": "ctrl+k",
    "command": "selectPrevSuggestion",
    "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
  },
  {
    "key": "ctrl+j",
    "command": "selectNextSuggestion",
    "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
  }
]

@SeeminglyScience i did not think about that. Added it in 0.0.4. Might take a few minutes to show up on the market place image

First, read the whole discussion before asking which is already been answered, second, use this extension, like it was said before: https://github.com/PascalSenn/keyboard-quickfix This replaces the quickfix context menu with the quick open window, which keybindings can be customized

My workaround is using the Hotkeys app

#IfWinActive, Visual Studio Code
^j::
Send, {Down}
return

#IfWinActive, Visual Studio Code
^k::
Send, {Up}
return

#IfWinActive, Visual Studio Code
^[::
Send, {Esc}
return

please fix this quickly

so sad, i am trying to bind the up/down to ‘j’, ‘k’, and blocked here. is there any workaround?

Well, I just figured out a solution for this issue, download AutoKey app for Linux and set this shortcut keyboard as you like. An example below with my preferences! image

🙂 This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!