IDE and terminal snippets
What is VS Code Snippets? An introduction to Microsoft's built-in snippet feature in Visual Studio Code
VS Code Snippets is the built-in snippet feature of Visual Studio Code, made by Microsoft. Snippets are templates for entering repeating code patterns such as loops or conditionals. They can come from a user's own JSON snippet files or from extensions.
- Tool
- VS Code Snippets
- Made by
- Microsoft
- Official site
- code.visualstudio.com/docs/editor/userdefinedsnippets
- Category
- IDE and terminal snippets
Who makes VS Code Snippets
VS Code Snippets is made by Microsoft as part of Visual Studio Code. It is a feature of the editor rather than a separate product, so there is nothing extra to install to use it. The official documentation page is linked below.
Official website: code.visualstudio.com/docs/editor/userdefinedsnippets
What VS Code Snippets is for
A snippet is a template for a code pattern you type often. Instead of writing a loop or a conditional by hand each time, you insert the template and fill in the parts that change. Snippets show up in IntelliSense and in a dedicated snippet picker, so they sit alongside the completions you already use. A setting can also enable tab-completion of snippet prefixes.
Visual Studio Code ships with built-in snippets for several languages, and many Marketplace extensions include snippets as well. You can also define your own without installing any extension. Your snippet files are JSON, they support comments, and they allow unlimited snippets.
Who VS Code Snippets is for
The vendor names three audiences. The first is Visual Studio Code users who want reusable templates for their own code. The second is extension authors who want to share snippets, which they can do through the public Extension Marketplace. The third is teams that want to share snippets inside a project.
Notable capabilities
The feature covers both the insertion of a template and the way you move through it afterwards. These are the capabilities documented for it.
- Prefixes: each snippet can define one or more prefixes that trigger it in IntelliSense.
- Tabstops and placeholders: you can jump between edit points inside an inserted snippet.
- Linked tabstops: repeated tabstops are linked and edited in sync.
- File templates: snippets can act as templates that fill a new or existing file.
- Global snippets: these are defined in .code-snippets files and can be scoped to chosen languages.
- Project snippets: snippet files in a project folder let a team share snippets within that project.
- Include and exclude globs: glob patterns control which files a snippet appears in.
- TextMate compatibility: the syntax follows TextMate snippet syntax with some exceptions, and TextMate .tmSnippets files are supported.
How VS Code Snippets fits IDE and terminal snippets
Within IDE and terminal snippets, VS Code Snippets is the editor-native option for people who already work in Visual Studio Code. Its templates live where completions appear, and its snippet files are plain JSON that can be edited like any other file.
In the wider niche of snippet managers, code paste and developer snippet tools, it covers insertion at the point of writing code rather than storage in a separate application. Because snippet files can be kept in a project folder, they can travel with a codebase and be shared with the people who work on it.
Frequently asked questions
What is VS Code Snippets used for?
It is used to insert templates for repeating code patterns such as loops or conditionals. Snippets appear in IntelliSense and in a dedicated snippet picker.
Who develops VS Code Snippets?
Microsoft develops it as a built-in feature of Visual Studio Code.
Can I create my own snippets in VS Code without an extension?
Yes. Users can define their own snippets without installing an extension, using JSON snippet files that support comments and allow unlimited snippets.
Does VS Code Snippets support TextMate snippets?
Snippet syntax follows TextMate snippet syntax, with some exceptions, and TextMate .tmSnippets files are supported.
Can a team share VS Code snippets?
Yes. Project-folder snippet files let a team share snippets within a project, and snippets can also be shared through the public Extension Marketplace.
Snipspire is independent and is not affiliated with Microsoft. Product names belong to their owners. Features change; confirm details on the official website.