Hot Snippet is a Visual Studio Code extension that helps quickly insert user-defined snippets.
Quick start
- Define your snippet normally according to https://code.visualstudio.com/docs/editor/userdefinedsnippets
{
"function": {
"prefix": "fx",
"body": [
"function($1) {",
"\t$0",
"}"
]
}
}
- Type the prefix, such as
fx
and immediately follow by a SPACE on your keyboard.
- Expect the prefix to be replaced with the matching snippet.
Advanced usage
This extension aims to solve the problem that adding a snippet from IntelliSense menu is too slow to show up. Developers who have fast-typing pace might get annoyed by the slowness of IntelliSense menu, especially in a big repository.
As soon as the extension is activated, it automatically sets editor.snippetSuggestions
to "off"
at user-level settings. This is to avoid redundant snippet suggestions offered by IntelliSense menu.
The extension reads your global-scoped and project-scoped snippets and monitors your keystrokes; whenever the key sequence matches the prefix
defined in the user snippets (File > Preferences > User Snippets) followed by a SPACE key, it replaces the prefix with the matching snippet.
The TextMate snippet syntax $TM_SELECTED_TEXT
will not work with this extension because you cannot have text selections while typing a prefix at the same time. Therefore, $HS_SELECTED_TEXT
variable is introduced instead.
Below is an example of how to create a snippet for JavaScript.
{
"const": {
"prefix": "cs",
"body": "const "
},
"log": {
"prefix": "lg",
"body": "console.log($HS_SELECTED_TEXT)"
}
}