A cli-tool for generating VSCode code snippets.
pnpm i -g csnp # recommend
npm i -g csnp
yarn i -g csnp
bun i -g csnpUsing interactive prompts to generate .csnp files for managing vscode code snippets.
The expected path for your snippets is:
.csnp/{SnippetType}/{SnippetName}.csnp
For example:
.csnp/js/log.csnp
SnippetType: js
SnippetName: logOpen the file .csnp/js/log.csnp and edit the default code snippets as follows:
---
name: Log
prefix: '-log'
description: log something
---
code snippets
- name: The name of the snippet.
- prefix: The trigger text for the snippet in editor.
- description: A brief description of what the snippet does.
- code snippets: The actual code that will be inserted.
Just edit and replace the line code snippets of console.log.
---
name: Log
prefix: '-log'
description: log sth
---
console.log($1)
After editing, use the command:
csnp pushThen in editor you need to type the prefix -log and press Enter to generate the code.
You can transform all .csnp files and store them locally or globally(in VSCode).
# local (default)
$ csnp push
# global (VSCode)
$ csnp push --globalTo sync all snippets from local or global(VSCode) and store them in .csnp directory.
# local (default)
$ csnp pull
# global (VSCode)
$ csnp pull --global# csnp -h
csnp --helpHow to use Snippet in Visual Studio Code.
MIT @ Junxio.


