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

混江龙づ霸主 提交于 2020-12-26 05:07:19

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/61078606/vscode-how-to-automatically-insert-intellisense-suggestions-without-having-to-pr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!