Kevin Yin
Kevin Yin

Reputation: 872

Prevent VS Code intellisense suggestion boxes from consuming up/down arrows

When I type "std::" in VS Code with Intellisense active, a dropdown appears with suggested completions. Then, pressing the down key will cycle through the dropdown. But I don't want to browse through the dropdown with my arrow keys; I want to move to the next line of code. Is there a way to make arrow keys ignore the dropdown without disabling dropdowns entirely?

Upvotes: 12

Views: 2047

Answers (1)

Mark
Mark

Reputation: 180657

Add these to your keybindings.json or find the selectNextSuggestion and selectPrevSuggestion commands in the Ketboard Shortcuts and disable them:

{
  "key": "down",
  "command": "-selectNextSuggestion",
  "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus || suggestWidgetVisible && textInputFocus && !suggestWidgetHasFocusedSuggestion"
},
{
  "key": "up",
  "command": "-selectPrevSuggestion",
  "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus || suggestWidgetVisible && textInputFocus && !suggestWidgetHasFocusedSuggestion"
}
// {
//   "key": "down",
//   "command": "your other command here",
//   "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus || suggestWidgetVisible && textInputFocus && !suggestWidgetHasFocusedSuggestion"
// }

The first disables the default DownArrow action when a suggest panel is open and the second makes the DownArrow do something else in that situation. You don't need the second keybinding since you only want the default action once the special selectNextSuggestion is disabled.

By the way, even with this these keybindings removed you can still use Ctrl+Up/Down to move the selection in the suggest widget.

Upvotes: 12

Related Questions