How to add custom code snippets in VSCode?

BeastCode picture BeastCode · May 2, 2015 · Viewed 80.3k times · Source

Is it possible to add custom code snippets in Visual Studio Code? And if so, how? VSCode is based on Atom, so it should be possible.

Answer

Chandan Nayak picture Chandan Nayak · Feb 15, 2016
  1. Hit > shift + command + p and type snippets
  2. Select Preferences: Open User Snippets
  3. Choose the language type for which you want to add the custom snippet
  4. vscode has comments to explain on how to add a snippet, as described on :> vsdoc

Lets say, we want to open custom snippets for the language GO. Then we can do:

  1. Hit > command + p
  2. Type: go.json + enter And you land on the custom snippet page

Snippets are defined in a JSON format and stored in a per user (languageId).json file. For example, Markdown snippets go in a markdown.json file.


Update new tools:
Snippet generator site: https://snippet-generator.app/