This feature now ships with visual studio code!
Steps to using built-in workspace snippets:
- Create a
{namehere}.code-snippets
file in.vscode
folder - The file must be within
.vscode
folder (not in sub-folders) - Your snippets can now be checked in and shared with your team
- Note: when using the snippet you will see
(Workspace Snippet)
in the intellisense autocomplete dropdown
Provide workspace/project level code snippets.
Put snippets at .vscode/snippets/<languageId>.json
For example, .vscode/snippets/javascript.json
{
// Place your snippets for JavaScript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
"console.log($1);"
],
"description": "Log output to console"
},
"Print to console error": {
"prefix": "error",
"body": [
"console.error($1);"
],
"description": "Log error output to console"
},
}
See this blog post for more info.
- rebornix
- thongdong7