1. Home
  2. Windows

Design And Manage Visual Studio Code Snippets With Snippet Designer

If you use ‘off the shelf components’ code modules in your Visual Studio projects on regular basis, you must’ve used Insert Snippet option which is accessible from VS editor right-click context menu. For those who never tried it before, it lets you access sample along with users-saved code snippets and insert them into current project’s source code files. Since Visual Studio doesn’t have an in-built code snippet manager to organize sample and saved snippets, you should try Snippet Designer. It’s an add-in for both Visual Studio 2008 and 2010, allowing users to not only organize code snippets but lets them design and export code snippets as well. With Snippet Designer enabled, you can select the code module present in your code file and export it to Snippet Designer which lets you define the variables used in snippet and save the snippet file. It also incorporate a small Snippet Explorer which is responsible to insert selected snippet into current code file and search snippet files from your code snippet library.

Snippet Designer can be used in two ways; you can either create a snippet file from scratch or export selected code module to Snippet Designer to further furnish the code. It adds a Snippet Designer option in New File dialog box (accessible from File -> New File). When accessed, it opens Snippet Designer to write a new code snippet.

add snippet

Export as Snippet option in right-click menu offers a quick way of creating a snippet.

export snippet 2

The snippet editor lets you make replacements for variables and other symbols, so they can be easily identified when you export the snippet in source code file, One you’ve entered the snippet, enter its name and language in which you’ve coded the snippet.  Now save the snippet under newly created My Code Snippets folder.

add snippet 2

When you want to enter the snippet into source code file, right-click the empty area in VS editor and select Insert Snippet. This will let you explore the snippets folder. Just move to My Code Snippets folder and select the required snippet file to insert it into your source code file.

insert snippet 1

You can access the Snippet Explore from Other Windows sub-menu present in main View menu. The Snippet Explorer lets you search through all the saved snippets by languages. Just choose the language of snippets you want to search, enter the keyword and hit Search button.

snippet explorer1

Snippet Designer proves to be a handy tool for those who save and use small code snippets from a third-party code snippet manager. It is an open source add-in and works on both Visual Studio 2008 and Visual Studio 2010. We tested it under Windows 7.

Download Snippet Designer

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.