Visual Studio… Code Snippets: no snippets manager?

.., no problem:

Keeping things simple, this is a basic snippet, that can act as a template. It has no parameters:


You will see that the Title and the ShortCut, and the filename, are all [MyTestMethodEmpty]. That helps with cataloguing and maintenance, I find.

So that is sitting on the file system in some scratch location, and we want to use it in Visual Studio.

These are the steps:

In Visual Studio, import the snippet you created earlier using any-old text editor (note that even though I intend to use this in C#, I have left the language at the default of Basic):


Browse to the location where you created/saved your snippet, and click [Open] ([Open] not shown in the screenshot):


The next dialog carries forward the named snippet, and suggests a location: this might be a default, or it might just be remembering my previous choice. I don’t care how it decided, this is fine for my purposes:


We then click [Finish]/[OK] (not shown here), and we return to the IDE.

There are 2 things to check: a) Does Visual Studio find the snippet, and b) where has it stored it?

a) Does Visual Studio find the snippet

In the IDE, I start to type [myt], and it finds the shortcut:


I then press tab twice… and it brings up the boilerplate that is clearly from the snippet I created (the squiggles are because I did the editing in a non-Test class). So this is clearly working:


b) where has it stored it?

I just don’t trust Windows Search (and that continues into Windows 10), so I use PowerShell to look for the wild card. Although it’s not efficient, on an SSD it goes pretty quickly. And this screenshot confirms on the file system what we asked for in the IDE, in that we created the file c:\temp, and Visual Studio must have followed the instruction to put in the [My Code Snippets folder].


gci -Path c:\ -Filter *empty*.snippet -Recurse -File -ErrorAction SilentlyContinue


As this are all pretty small, it is valid to take the whole content of the Code Snippets parent folder, and back that up – 25 files looks a bit suspiciously small, so maybe validate that before putting faith in the backup, but you get my point regarding size:


Blue below represents the things you would change in a template without parameters:

<?xml version=”1.0″ encoding=”utf-8″?>
<CodeSnippets xmlns=””&gt;
<CodeSnippet Format=”1.0.0″>
<SnippetTypes />
<Keywords />
<References />
<Imports />
<Declarations />
<Code Language=”csharp” Kind=”” Delimiter=”$”><![CDATA[[TestMethod]
public void TestMethod() {


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s