VS Code Snippets: Write Code Faster
Ad
What are Snippets?
Snippets are reusable code templates you trigger with a short prefix — type a few letters, hit Tab, and expand into full boilerplate.
Built-in Snippets
// In a JS file, type and press Tab:
log → console.log()
for → for loop
func → function
Creating Custom Snippets
Command Palette → "Configure User Snippets" → pick a language:
{
"Console Log": {
"prefix": "clg",
"body": ["console.log($1);"],
"description": "Quick console.log"
}
}
Placeholders & Tab Stops
"body": [
"function $1($2) {",
" $3",
"}"
]
// $1, $2, $3 = tab through them; $0 = final position
Snippet Extensions
Install snippet packs like "ES7+ React/Redux snippets" for ready-made templates (rfc → React component).
FAQs
Are snippets per-language?
Yes — or global for all files. More in our VS Code guides.
How do I trigger a snippet?
Type the prefix and press Tab (or Enter from the suggestion list).
