π‘ How to use:
-
Fill all required fields (name, prefix, body). Optionally add a
description or import.
-
In the body field, type special shortcuts for rapid snippet
writing:
$ β inserts $1, then $2, etc.
var β inserts $1 (or next placeholder)
Var β inserts ${1maj},
filename β ${TM_FILENAME}, etc.
{ ( [ " ' β auto close pairs
See full list below!
-
Click "Generate Snippet" and paste the JSON into your
lua/snippets/ folder.
β Snippet Format
{
"snippet_name": {
"prefix": "trigger",
"body": [
"line 1",
"line 2 with ${1:placeholder}"
],
"description": "Optional",
"import": "import Something from 'somewhere';"
}
}
π Placeholders & Tricks
Basic Placeholders
$1 β First placeholder
$2 β Next placeholder
$0 β Final cursor position
Defaults
${2:default} β Placeholder with default
${1:myVar} β Default var name
Transforms
${1cap} β Capitalize first
${1pascal} β PascalCase
${1camel} β camelCase
${1snake} β snake_case
${1upper} β UPPERCASE
${1lower} β lowercase
ποΈ Special TM_ variables (auto-filled)
${TM_FILENAME} β Full file name
${TM_FILENAME_BASE} β File name, no extension
${TM_DIRECTORY} β Full path to file's directory
${CURRENT_YEAR}, ${CURRENT_MONTH},
${CURRENT_DATE} β Date
${CURRENT_HOUR}, ${CURRENT_MINUTE} β Time
${CLIPBOARD} β Current clipboard content
π Pro Tip: Use these for auto-filled metadata/comments!
All snippets are saved in ~/.config/nvim/lua/snippets/ (see
your config README).