csnp
v1.4.1
Published
A cli-tool for generating VSCode code snippets.
Downloads
34
Maintainers
Readme
Install
pnpm i -g csnp # recommend
npm i -g csnp
yarn i -g csnp
bun i -g csnp
csnp
Using interactive prompts to generate .csnp
files for managing vscode code snippets.
Rule csnp Path
The expected path for your snippets is:
.csnp/{SnippetType}/{SnippetName}.csnp
For example:
.csnp/js/log.csnp
SnippetType: js
SnippetName: log
Details
Open 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 push
Then in editor you need to type the prefix -log
and press Enter to generate the code.
Transforming Snippets
You can transform all .csnp
files and store them locally or globally(in VSCode).
# local (default)
$ csnp push
# global (VSCode)
$ csnp push --global
Syncing Snippets
To sync all snippets from local or global(VSCode) and store them in .csnp
directory.
# local (default)
$ csnp pull
# global (VSCode)
$ csnp pull --global
Usage Information
# csnp -h
csnp --help
Links
How to use Snippet in Visual Studio Code.
License
MIT @ Junxio.