Snippet Scope

Snippets can be scoped on three levels (in order of the priority):

  1. Project

  2. Language

  3. Global

../../_images/vscode-select-snippets-file.png

Tip

In the Existing Snippets section you can see the snippet scope between the brackets.

Project Scope

The files are located in the root of the project inside the .vscode folder and must have the .code-snippets suffix.

Project snippet files are useful for sharing snippets among team members working on the same project.

Language Scope

These snippets are defined in a specific language’s snipet file (for example systemverilog.json or vhdl.json). These snippets are available only when editing a file that has the specified language.

The language snippets are serialized in the user data directory.

Global Scope

These snippets are also serialized in the user data directory and must have the .code-snippets suffix. The global snippets are available in all editors, regardless of the language.

Note

Snippets saved in the user data directory are, by default, located at $HOME/.config/Code/User/snippets.

Tip

In a snippets file located at the project or global level, you can include an additional scope property that accepts one or more language identifiers. This makes the snippet available only in editors using the specified languages.

../../_images/vscode-scope-field-snippet.png

To learn more about the other properties, see the Create your own snippets chapter from the VS Code documentaion.