https://code.visualstudio.com/docs/editor/userdefinedsnippets
Create your own snippets
- Create
*.code-snippets
file in.vscode
folder
Below is an example of a for
loop snippet for JavaScript:
prefix
defines one or more trigger words that display the snippet in IntelliSense. Substring matching is performed on prefixes, so in this case,"fc"
could match"for-const"
.body
is one or more lines of content, which will be joined as multiple lines upon insertion.
Additionally, the body
of the example above has three placeholders (listed in order of traversal): ${1:array}
, ${2:element}
, and $0
. You can quickly jump to the next placeholder with Tab
, at which point you may edit the placeholder or jump again the next one. The string after the colon (if any) is the default text, for example element
in ${2:element}
. Placeholder traversal order is ascending by number, starting from one; $0
is an optional special case that always comes last, and exits snippet mode with the cursor at the specified position.