Search code examples
visual-studio-codeautocompletecode-snippetsvscode-snippets

How to make VSCode snippets that trigger only in double quote


I want to create a small VSCode plugin that has autocomplete function for the Bootstrap classes.

I would like this autocomplete to work only when the cursor is between double quotation marks. enter image description here

Is it possible to restrict the display of the auto-complete list only for this range?

I tried something like this:

"BTN": {
    "scope": "string.quoted.double.html",
    "prefix": "work-btn",
    "body": [
        "test-class;",
    ],
    "description": "BS4"
}

but not working


Solution

  • It isn't possible to use syntax scopes in a snippet, see the discussion at

    https://github.com/microsoft/vscode/issues/71187

    I was going to suggest upvoting that issue but it has been locked. The functionality seems like it would be useful for various reasons, but might be cpu-intensive.