Using the Code Snippets Manager

Keyboard:  CTRL + K, CTRL + B
Menu:  Tools -> Code Snippets Manager
Command:  Tools.CodeSnippetsManager
Versions:  2008,2010
Published:  4/23/2010
Code:  vstipTool0015

 

image

 

Have you used code snippets before?  Ever wonder where the heck you can get a list of them just to browse and see what is there?  Have I got a deal for you!  The Code Snippets Manager is your friend.  Start by pressing CTRL + K, CTRL + B:

image

 

The first thing you need to do is pick the language you want to browse through:

image

 

Go ahead and choose "Visual Basic" for this example.  This will give you tons of folders (categories) to choose from.  I'm going to choose the "Application" folder:

image

 

From here you can browse individual snippets and mouse over each of them to get the full description:

image

 

Click on the "Change the Foreground and Background Colors in a Console Window" snippet.  Notice there is summary information about the snippet:

image

 

Now it would be nice if you could just Double-Click the snippet and it would insert it at the current cursor location.  Sadly, it doesn't do that so, in order to use this snippet, we have to copy the shortcut name:

image

 

And then click "OK" or "Cancel" (as near as I can tell both buttons do the same thing so I'm not sure why they are both there instead of a "Close" button).  Now, you just need to paste your shortcut:

image

 

Then press TAB twice to get the results (NOTE: Technically, you only have to hit TAB once in this case but hitting it twice preserves muscle memory for the snippets and has no downside.):

image

 

 

Great!  But what about the buttons in the Code Snippet Manager we didn't talk about? 

image

 

Here is what they do:

Add - Let's you pick a folder to add to the current list of folders for snippets.  The folder can be any accessible location including network drives. 

Remove - Will take a folder out of the list but does not physically delete the folder.

Import - Used to include individual .snippet files in the current folder you are viewing.