Visual Studio Code: Use tab (instead of arrow keys) to select Intellisense Suggestions?
Asked Answered
C

5

17

Much like in ipython, is it possible in VScode to use tab to select options from intellisense instead of using arrow keys?

Christianity answered 4/1, 2018 at 14:36 Comment(0)
N
37

In your keybindings.json:

  {
    "key": "tab",
    "command": "selectNextSuggestion",
    "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
  },
  {
    "key": "down",
    "command": "-selectNextSuggestion",
    "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
  },
    {
    "key": "ctrl+tab",
    "command": "selectPrevSuggestion",
    "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
  },
  {
    "key": "up",
    "command": "-selectPrevSuggestion",
    "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
  }
Nuncupative answered 4/1, 2018 at 15:9 Comment(5)
The "down" entry removes the keybinding to the command selectNextSuggestion - note the "minus" sign before the command selectNextSuggestion. I included that because the OP said he doesn't want to use the arrow keys normally bound to selectNextSuggestion, but it isn't necessary to remove it if you want to use both tab and down arrow.Nuncupative
I see. The reason I asked is because I could still use my down arrow key with the setting enabled, although the tab setting did workArlenarlena
I added select-on-enter for the alternatives, too: { "key": "enter", "command": "acceptAlternativeSelectedSuggestion", "when": "suggestWidgetMultipleSuggestions && textInputFocus && textInputFocus" }Expurgate
You are my heroCoseismal
I upvoted this, but it interferes with snippet navigation for me. I have added an answer for snippet navigation as well as removed the entries removed as mentioned in above comments. Still this answer worked great as a starting point and was a huge help for me so much appreciated.Salamander
S
3

friendlier with snippet navigation

{
    "key": "tab",
    "command": "-acceptSelectedSuggestion",
    "when": "suggestWidgetHasFocusedSuggestion && suggestWidgetVisible && textInputFocus"
},
{
    "key": "tab",
    "command": "selectNextSuggestion",
    "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus && !inSnippetMode"
},
{
    "key": "shift+tab",
    "command": "selectPrevSuggestion",
    "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus && !inSnippetMode"
}

Note that this...

  • keeps arrow-key navigation enabled
  • uses shift+ paradigm to select previous suggestion instead of ctrl+ (which I was not aware of)
  • also works with VsCodeVim extension enabled
Salamander answered 6/2 at 23:17 Comment(0)
J
1

Here is my one. (keybindings.json)

{
    "key":"alt+0",
    "command":"selectNextSuggestion",
    "when":"suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
    "key":"alt+9",
    "command":"selectPrevSuggestion",
    "when":"suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
}
Jacquelynnjacquenetta answered 31/3, 2022 at 15:32 Comment(0)
K
1

go to settings>Open Settings(JSON) And add

"editor.tabCompletion":"on"

Save and done.

Note: If there is not json object there than you need to add like {"editor.tabCompletion":"on"}

Kearney answered 13/11, 2023 at 13:20 Comment(0)
S
0

Here is the answer from @Mark in the right format for your keybindings.json assuming your start from an empty keybindings.json (can be found easily via F1 menu):

[
    {
        "key": "tab",
        "command": "selectNextSuggestion",
        "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    },
    {
        "key": "down",
        "command": "-selectNextSuggestion",
        "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    },
    {
        "key": "ctrl+tab",
        "command": "selectPrevSuggestion",
        "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    },
    {
        "key": "up",
        "command": "-selectPrevSuggestion",
        "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    }
]
Scanties answered 16/11, 2022 at 16:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.