Home > Software engineering >  vscode Make snippet first choice when hitting tab
vscode Make snippet first choice when hitting tab

Time:06-06

I wrote my own simple snippet for const in javascript:

const should trigger const ${1} = ${0};

and it works very well. However, when I enter const and the available options pop open in the menu, I do not get the snippet as a first, but as a second option which means I first need to go down one step with an arrow and then I can select it with tab.

I'm coming from vim where evert keystroke matters in terms of productivity and this is annoying me so much that I decided to write here no stackoverflow. Does anyone know how I can make it the first option if it matches the snippet?

Also, does anyone know what the first option actually means?

const Snippet vscode

CodePudding user response:

In settings.json

{
    "typescript.useCodeSnippetsOnMethodSuggest": true,
    "editor.snippetSuggestions": "top",
    "editor.tabCompletion": true
}

By default, editor.snippetSuggestions is bottom so setting it to top wil show it at top.

Note: both standard and your custom snippets will be show in suggestion.if you want your snippet to go above the standard - you can change description so that it sorts at top.

You can see about it here(github link)

  • Related