Snippets
Snippets are a folder of VS Code .code-snippets files. The default is the snippets folder inside the app data folder. Choose another folder in Settings → Workspace, or leave the field blank to use that default. It is not a Note workspace.
Snippets in the jump list (Ctrl+J), or Ctrl+Shift+S (Cmd+Shift+S on macOS), opens the page in the terminal column and hides the prompt. Press the same keys again, or Esc, to return to the terminal. Esc stays in a field while you are typing there.
The search box matches a snippet name or a prefix. The count under the box is how many rows match, then how many the folder holds. Each row shows the name, the prefix, and how many blanks the body has. The file name is not shown in the list.
New snippet starts a draft. The list stays unselected until you save. The file field is the name only. Termorq adds .code-snippets when it saves. A snippet also needs a name and a prefix. A prefix with a comma is stored as more than one prefix. A body with a line break is stored as a list of lines, which is the VS Code shape. Save snippet writes that file back into the folder.
Import adds a .code-snippets file to the folder. Tab stops such as $1 and ${1:name} stay as they are. A variable ($TM_FILENAME) is reported and left unchanged. A choice stays in the file as written.
Export writes one .code-snippets file to a path you choose. An unsaved draft in that file is included.
In the prompt
Type a prefix exactly, then press Tab. klogs expands. kl does not, and neither does a path such as src/App.tsx, so path completion still runs.
The description shows as ghost text after the prefix. Tab does not type that description.
In the snippet body, a blank is ${1:name}. $1 is the same blank again. {{name}} is not a blank. That syntax belongs to endpoints and workflows.
For this body:
echo ${1:name}
echo ${2:ns}type the prefix and press Tab. The prompt becomes:
echo name
echo nsname is selected. Type ada and it replaces name. Tab selects ns. Type prod. Shift+Tab selects ada again. Enter sends both lines once. Shift+Enter adds a line and does not send.
Tab selects the next blank. Shift+Tab selects the previous one. The same number is one blank: typing replaces every place that number appears, as you type. $0 is last. A variable ($TM_FILENAME) stays as written.
A choice lists options:
kubectl get ${1|pods,svc|}Type the prefix and press Tab. The prompt shows kubectl get pods, with pods selected. Down selects svc. Up selects pods again. Type deployments to replace the option. Tab moves to the next blank. Up and Down stay on the choice. They do not recall an older command.
An empty option is a trailing comma. This body:
cat ${1|-n,|} ${2:file}starts as cat -n file, with -n selected. Down removes -n. Up puts -n back. Tab selects file.
{
"Logs": {
"prefix": "klogs",
"body": [
"echo ${1:name}",
"echo $2"
],
"description": "Print two values"
}
}That file is one snippet named Logs. Its prefix is klogs. The body is two lines.
Related
The prompt is where a finished snippet is typed. Keyboard shortcuts lists Ctrl+Shift+S.