This extension contains keyword snippets and micro patterns for JavaScript, TypeScript and JSON.
- Added
using
andawait using
. - Added
Symbol.dispose
andSymbol.asyncDispose
. - Added
${clipboard}
and${selection}
for keyboard shortcut usage. - Eliminated duplicated prefixes with value selection.
- Removed primitive types for functions, getters, setters, methods and types.
- Removed
typeof value !== ...
.
- Introduction
- Shortcut rules for JavaScript
- Shortcut rules for TypeScript
- Recommended Settings
- Recommended Keyboard Shortcuts
- Recommended Extensions
The idea of those snippets is to create a workflow with micro patterns. Write one to five characters and you get the keyword or pattern.
Some prefixes are twice, because the rules are matching different patterns like s_
-> set NAME () { ... }
and static NAME () { ... }
. Then you have to pick the right one.
The following prefixes are just examples to explain the rules. To see the complete list, please visit SNIPPETS.md. If a keyword or pattern might be missing, please open an issue on Github and make a suggestion.
Prefix | Snippet |
---|---|
a |
await |
f |
false |
t |
true |
Prefix | Snippet |
---|---|
_ |
NAME () { ... } |
i_ |
if (...) { ... } |
f_ |
function NAME (...) { ... } |
af_ |
async function NAME (...) { ... } |
d_w |
do { ... } while (...); |
Prefix | Snippet |
---|---|
cl$ |
console.log(); |
Jp$ |
JSON.parse(); |
Prefix | Snippet |
---|---|
i1 |
if (CONDITION) ...; |
c1 |
const NAME = VALUE; |
l1 |
let NAME = VALUE; |
Prefix | Snippet |
---|---|
$_ |
() => { ... } |
$1 |
() => |
Prefix | Snippet |
---|---|
n_ |
namespace NAME { ... } |
i_ |
interface NAME { ... } |
ie_ |
interface NAME extends NAME { ... } |
t1 |
type NAME = TYPE; |
t_ |
type NAME = { ... }; |
Prefix | Snippet |
---|---|
__ |
private NAME () { ... } |
_a1 |
private NAME:any = null; |
_b_ |
private NAME () :boolean { ... }; |
_ik |
{ [K in keyof T]: ... }; |
It is recommended to set the snippet suggestions to top.
It is recommended to disable auto intellisense for snippet.
"editor.suggest.snippetsPreventQuickSuggestions": true
It is also recommended to hide the built-in JavaScript and TypeScript snippets.
-
Open a JavaScript file
-
Open command palette
-
Run
Snippets: Insert Snippets
-
Hide all
JavaScript Language Basics
snippets from Intellisense -
Open a TypeScript file
-
Open command palette
-
Run
Snippets: Insert Snippets
-
Hide all
Typercript Language Basics
snippets from Intellisense
Please have the following keyboard shortcuts always in mind, because these are fundamental to get the most out of it. Every tab stop is used only if necessary, because it prevents VS Code to open the IntelliSense menu automatically. So sometimes DownArrow
or Cmd/Ctrl + Enter
can have the same effect.
Tab
- Jump to the next tab stop of the snippet.DownArrow
- Move the caret down one line.Cmd + Enter
- Insert line below, even if the caret is in the middle of a line.Cmd + Shift + Enter
- Insert line above, even if the caret is in the middle of a line.
Tab
- Jump to the next tab stop of the snippet.DownArrow
- Move the caret down one line.Ctrl + Enter
- Insert line below, even if the caret is in the middle of a line.Ctrl + Shift + Enter
- Insert line above, even if the caret is in the middle of a line.
The following keyboard shortcut improves the writing of an expression in template literals.
[
{
"key": "cmd+-",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus && !editorReadonly && editorLangId =~ /(java|type)script(react)?/",
"args": { "name": "${selection}" }
},
{
"key": "alt+cmd+-",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus && !editorReadonly && editorLangId =~ /(java|type)script(react)?/",
"args": { "name": "${clipboard}" }
}
]
[
{
"key": "ctrl+-",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus && !editorReadonly && editorLangId =~ /(java|type)script(react)?/",
"args": { "name": "${selection}" }
},
{
"key": "alt+ctrl+-",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus && !editorReadonly && editorLangId =~ /(java|type)script(react)?/",
"args": { "name": "${clipboard}" }
}
]