milanHrabos
milanHrabos

Reputation: 1965

vscode: how to make text after snippet *not* selected?

When a snippet (for whatever language) is triggered, and the cursor is moved to a tab-stop, the area is "selected" (that is, you are still in "snippet mode" where you can go to another tab-stop). But I would like to get out of this "snippet mode" (e.g not having the area selected after tab-stop), because it suppresses intellisense (the selected area after snippet was triggered accepts anything, so it does no longer suggest intellisense function, variables, etc. Is there a settings in vscode to disable this "selection" after snippet is triggered?

Upvotes: 4

Views: 751

Answers (2)

Gustavo Silva
Gustavo Silva

Reputation: 61

If you have only one tabstop you can use $0 to avoid the "selecttion".

But if you have more than one i don't think it's possible.

Upvotes: 3

Guillermo Brachetta
Guillermo Brachetta

Reputation: 4775

I don't believe that's possible.

Snippets often have placeholders such as ${1:name} to indicate what's expected in that tab stop.

Take this one for example:

"JS arrow function": {
    "prefix": "af",
    "body": [
        "const ${1:name} = (${2:props}) => {",
        "\t$3",
        "}"
    ],
    "description": "Create arrow function"
}

Using tab will cycle over $1, $2 and $3, and for $1 and $2 there is a placeholder.

You can omit the placeholders if you want:

"JS arrow function2": {
    "prefix": "af2",
    "body": [
        "const $1 = ($2) => {",
        "\t$3",
        "}"
    ],
    "description": "Create arrow function"
}

But instellisense won't work until you press escape.

You can add your own snippets globally or per language if you prefer to customise them and avoid placeholders.

See this link for more information.

Upvotes: 0

Related Questions