Home > database >  How to add snippets through custom extension?
How to add snippets through custom extension?

Time:09-16

I want to make all my tools into one extension including snippets, I know how to add snippets by steps operations, and how to make an extension, but how can we add snippets by making and installing an extension?

CodePudding user response:

You can add contribution point 'snippets' in package.json .

{
  "contributes": {
    "snippets": [
      {
        "language": "go",
        "path": "./snippets/go.json"
      }
    ]
  }
}
  • The language attribute is the language identifier.
  • The path is the relative path to the snippet file.

Here are official references : https://code.visualstudio.com/api/references/contribution-points#contributes.snippets

or

You can also choose New Code Snippets when creating an extension project with yo code command. This way is useful to create an extension just for snippets.

Hope this helps!

  • Related