Skip to content

VSCode extension which lets you manage your code snippets without quitting your editor.

License

Notifications You must be signed in to change notification settings

ryanmcfall/snippets

 
 

Repository files navigation

Visual Studio Marketplace Version Visual Studio Marketplace Installs Visual Studio Marketplace Downloads Visual Studio Marketplace Rating GitHub Repo stars GitHub Workflow Status (with event) The MIT License

Snippets — Supercharge Snippets in VS Code

Code snippets are valuable additions for anyone looking to save time during development. They simplify the process of entering repetitive code, such as loops, complex HTML structures or reusable methods.

Visual Studio Code already provides robust support for snippets, including their appearance in IntelliSense, tab-completion, and a dedicated snippet picker (Insert Snippet in the Command Palette). This extension takes snippets to another level by introducing new features that enhance code snippet management.

Getting Started

Install Snippets by one of the following options:

  • clicking Install on the banner above
  • searching for Snippets from the Extensions side bar in VS Code
  • typing ext install tahabasri.snippets from the Command Palette in VS Code

Features | FAQ | Known Issues | Release Notes | Feedback | Credits

Features

Boost your productivity with a set of powerful features that enhance snippet management:

  • Create — Create Snippets easily with few clicks.
  • Open — Open Snippets quickly from anywhere in VS Code.
  • Search — Find your Snippet in 2 seconds, or less...
  • Manage — Organize your snippets freely, with no forced order, beyond editing and deleting.
  • Customize — Personalize your Snippets to match your style.
  • Sync — Various options for synchronizing your snippets across multiple devices and users.
  • Boost — Supercharge your snippets to make them more developer-friendly.

Create

Create Snippet from open editor

Create Snippet

Create Snippet directly from the clipboard

Create Snippet from Clipboard

Create Snippet manually

Create Snippet Manually

Open

Open Snippet with a single click

Open Snippet

Drop Snippet directly into the editor

You may need to hold Shift key while dragging to correctly drop the item in the editor.

Open Snippet

Copy Snippet to Clipboard

Copy Snippet to Clipboard

Insert Snippet directly into Terminal

Open Snippet in Terminal

Search

Use IntelliSense to quickly access all your Snippets

You can set a special key to trigger IntelliSense from the extension settings. Default key is >. More about IntelliSense here.

Open Snippet using Suggestions

Search for Snippets using Command Palette

Open Snippets from Command Palette

You can also search directly into the Snippets view similarly to the File Explorer.

Native Search

Preview Snippets before insertion

Preview Snippets

Manage

Drag and drop Snippets from one folder to another

Drag and Drop Snippets

Reorder Snippets using Up and Down actions

Reorder Snippets

Sort alphabetically a Snippets folder or all your Snippets

Reorder Snippets

Customize

Set icons for your folders

Set Folder Icon

Add a description to your Snippet

Descriptions show when hovering on top of a Snippet and in IntelliSense.

Set Snippet Description

Add a prefix to your Snippet

When displaying Snippets using IntelliSense, custom prefix will be used instead of the original Snippet label. A prefix is a recommended shortcut for Snippets with long labels.

Set Snippet Prefix

Prefix all your Snippets

You can set a prefix for all your snippets to distinguish them from other VS Code snippets.

  • set a keyword for the setting Snippets: Global Prefix e.g snipp
  • suggestions coming from your custom Snippets will be prefixed in IntelliSense

An explicit prefix in a single Snippet will override Global Prefix settings.

For example, if the global prefix in your settings is set to foo, and a custom snippet is explicitly prefixed with boo, the latter will be displayed in IntelliSense as boo. All other snippets with no explicit prefix will be displayed as foo.

Global Prefix

Sync

Import and Export Snippets using JSON files

Import and Export Snippets

Sync Snippets between multiple devices

⚠ Experimental feature: feel free to file a bug as this is still an experimental change.

Starting with version 2.0 and up, Snippets supports backup using VS Code Settings Sync feature. Your snippets will be saved alongside your VS Code data no matter your operating system.

Check the docs to know more about Settings Sync feature and how to use it.

Sync your Snippets with a Version Control System

A large number of users utilize a VCS (e.g Git) and may need to associate a set of snippets with a specific project (e.g sharing project-specific snippets with team members). This can be achieved by enabling the snippets.useWorkspaceFolder setting. Once this option is enabled, the extension will read/write snippets to/from the .vscode/snippets.json file if it's available (the extension will prompt you to create the file the first time you enable this option).

Note: Workspace snippets are excluded from synchronization via Settings Sync. You will be responsible for backing up the .vscode/snippets.json file using your favorite VSC.

Boost

Bind Snippets to Programming Languages

Snippets created from a language specific editor/file will keep reference of the programming language used. The same Snippet will be suggested only in editors/files of same programming language.

A Snippet bound to a programming language will get an icon for that particular language natively.

Bind Snippets to Languages

You can explicitly set a programming language by appending the language file extension to the Snippet name at the creation prompt.

Manually Bind Snippets to Languages

Resolve Snippet Syntax

Learn more about the Snippet syntax here.

Option to Resolve Snippet Syntax is disabled by default for new Snippets, you may need to edit the Snippet to enable it.

Open Snippet with Variables

Enjoy!

FAQ

Q: Is there a limit on the number of snippets/folders I can create?

A: There is no limit; your disk space is the only limitation.

Q: I'm feeling overwhelmed by multiple snippets. How can I better organize them?

A: Check this section for available organizational features

Q: Clicking "Request to Initialize File" does nothing. What should I do?

A: If you're attempting to initialize the snippets file for a new workspace and nothing happens, ensure that the path to your current folder open in VS Code has the correct file permissions.

Known Issues

Troubleshoot Snippets

  • The new "Troubleshoot Snippets" option helps fix common issues, including:
    • Old snippets not appearing.
    • Moving snippets not working.
    • New snippets disappearing.

These issues often arise when two conflicting features, moving snippets and syncing them simultaneously, are in use. Fortunately, no snippets should be permanently lost. They are all stored locally, but inconsistencies in the database can make the snippets temporarily invisible.

Fix Snippets

Files Permissions on Windows

You may encounter some inconsistencies when dealing with snippets on Windows. The first thing to check is whether all related VS Code files are accessible and if any folder permissions are affecting accessibility.

Release Notes

Check the CHANGELOG for full release notes.

Feedback

Credits

About

VSCode extension which lets you manage your code snippets without quitting your editor.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 86.8%
  • HTML 5.7%
  • JavaScript 4.6%
  • CSS 2.9%