0.1.0 • Published 5 years ago

@ncko/snippet v0.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Snippet

Manage VS Code snippets from the command line.

Installation

First install the package globally

> npm install -g @ncko/snippet

Then run the config command.

> snippet config

Now you're ready to use it!

Usage

After installing and running the config command. Create a new snippet stub:

> snippet stub MySnippet mysnip

A new file appears in your current directory called ./snippet.snippet:

Title: MySnippet
Prefix: mysnip
-------------------------------------------
snippet body here
-------------------------------------------

Edit the body of this file like so:

Title: MySnippet
Prefix: mysnip
-------------------------------------------
console.log("My first snippet!");
console.log("I can set tabstops with defaults like this:", ${1:thing});
-------------------------------------------

Now that your stub is complete, you can write the snippet to VS Code's snippets directory.

> snippet write snippet.snippet javascript

Now, open a javascript file in VS Code, type mysnip and hit tab.

Commands

  • snippet config - After installation, this command must be run to set the folder that snippets will be managed in

  • snippet stub - generate a stub for a new snippet in the current directory

  • snippet list <language> - List all snippets for a given language

  • snippet view <language> <prefix> - View a specific snippet

  • snippet export <language> <prefix> - Export a snippet to local file (default: ./snippet.snippet)

  • snippet write <path-to-snippet-file> <language> - Write a snippet from a local file (default: ./snippet.snippet) to a VS Code snippet file

  • snippet remove <language> <prefix> - Delete a snippet

Contributing

If you'd like to help, please send a pull request! There is still some work to be done. Check the issues tab.