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
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:
The first thing you need to do is pick the language you want to browse through:
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:
From here you can browse individual snippets and mouse over each of them to get the full description:
Click on the "Change the Foreground and Background Colors in a Console Window" snippet. Notice there is summary information about the snippet:
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:
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:
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.):
Great! But what about the buttons in the Code Snippet Manager we didn't talk about?
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.
Comments
- Anonymous
November 12, 2010
The comment has been removed - Anonymous
November 12, 2010
blogs.msdn.com/.../inserting-code-snippets-vstipedit0051.aspx