Big_Boulard
Big_Boulard

Reputation: 1335

User Snippets for Svelte in VSCode

I struggle to create a simple snippet for .svelte files or Svelte project. Here's the procedure i've tried:

  1. Ctrl + Maj + P to open "Preference: Configure user Snippets"
  2. New Global Snippets File ... typed svelte to create the svelte.json file
  3. Inside of it the below code
{
  "test": {
    "scope": "Svelte",
    "prefix": "xx",
    "body": ["This is a simple test"],
    "description": "Code snippet for testing"
  }
}

Any idea ?

Upvotes: 2

Views: 1108

Answers (1)

Mark
Mark

Reputation: 182421

The scope id for Svelte is probably svelte lowercase. If you click on the Svelte language id button in the lower right when you have a .svelte file open, you can look through those language ids for svelte - the correct version to use is that in the parentheses like

Svelte (svelte) use the version in parentheses - svelte lowercased

{
  "test": {
    "scope": "svelte",
    "prefix": "xx",
    "body": ["This is a simple test"],
    "description": "Code snippet for testing"
  }
}

Works fine in a .svelte file.

You do not need to remove the scope selector but it is redundant if it is already inside the svelte.json file which limits all snippets within it to that filetype.

Upvotes: 2

Related Questions