skip to Main Content

I love snippets and use dozens all the time, but am constantly frustrated by the fact I cannot figure out how to make VSCODE guess what I am typing while I am typing inside a tab stop of a snippet.

If my snippet has

\$${1:variable_name}, \$${2:variable_two} 

inside it, the tabs work perfectly and put me right inside the text variable where I want to type, but if a variable for example is two lines above this insertion point of the snippet like

$variable_name_here = ‘some value.’;

when I tab into my snippet and begin typing v..a..r the $variable_name_here never autofills or hints at the fact that it’s even listening.

Then I tab out of the snippet and type v..a..r and it immediately guesses that I want "variable_name_here" to go in there.

I am sure it’s my settings. I have tried toggling many of the editor snippets settings in the settings.json file and such all with no joy.

THANKS.

2

Answers


  1. in settings (Ctrl+,) go to the search bar and type in quick suggestions and then enable them for strings. that will add suggestions inside tab stops. alternatively if you have the same variables you are using all the time you can set up choices in snippets like so,

    ${1|Red,Cyan,Green,Blue,Magenta,Yellow,White|}
    

    that will autofill the first option as red similar to if you typed

    ${1:Red}
    

    and give you a nice dropdown of all those options.

    Login or Signup to reply.
  2. I take it you are not using vscode v1.80+ as the default for the following setting recently changed.

    If using a version older than v1.80, disable/uncheck this setting:

    Editor > Suggest : Snippets Prevent Quick Suggestions
    

    Then you should get suggestions even within a snippet for words in certain documents, depending on your chosen option for the Editor: Word Based Suggestion Mode.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search