VSCode how to automatically insert Intellisense suggestions without having to press Enter?
Asked Answered
C

2

8

Default VS Code Intellisense behaviour

  • User is presented with a menu of suggestions
  • User then has to press the Up or Down arrow keys to navigate through the menu
  • Finally user has to confirm with Enter to insert the suggestion and close the dialog

What I would like instead

  • Don't need to press Enter
  • Suggestions are automatically inserted (and cycled through) by pressing Up/Down
  • Pressing any other keys will close the dialog and resume typing

To be clear, I want to replicate the default behaviour of YouCompleteMe:

When you type, a completion menu pops up. If you like the completions, you use the <Tab> key (by default, can be changed to <Enter> or <Down> arrow or whatever) to select a completion string you want. The very act of "tabbing through" the list to select the item you want inserts the candidate string. When you tab to a different candidate, the editor code is replaced with the new candidate. There is no accept key because by the point where you have the candidate you want selected in the menu the candidate has already been inserted in the editor. There is nothing to "accept". You just keep typing, the candidate has already been inserted.


Is such behaviour possible with Visual Studio Code, either by default or through a plugin?

Choir answered 7/4, 2020 at 11:7 Comment(0)
C
4

The editor.tabCompletion option is the closest thing currently available:

By default, tab completion is disabled. Use the editor.tabCompletion setting to enable it. These values exist:

  • off - (default) Tab completion is disabled.
  • on - Tab completion is enabled for all suggestions and repeated invocations insert the next best suggestion.
  • onlySnippets - Tab completion only inserts static snippets which prefix match the current line prefix.

(Emphasis mine)


... except that the first Tab press hides the suggestion window.

I did some digging about editor.tabCompletion, and I found that closing the suggestion window is part of the tab completion's option original design, and that while other users have asked about an option not to close the suggestion window or specifically YouCompleteMe-style behaviour, that this is currently not supported.

Choir answered 10/4, 2020 at 17:3 Comment(0)
M
1
"editor.acceptSuggestionOnEnter": "off",

To disable Enter to accept suggestion.

Measures answered 1/4, 2022 at 22:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.