Using Code Snippets in Visual Studio 2005 is Incredible

Visual Studio 2005 code snippets are a neat way to package pieces of code that you want to keep close at hand. These can be code samples that you've created or samples that you find during searches. And creating them is pretty easy with some of the free editors that are available. Such as:

Visual Basic 2005:,289483,sid8_gci1173726,00.html


I recently created and posted over 100 code snippets on the Microsoft Office Developer Center (http:\\Office) to customize the Office Fluent Ribbon in Visual Basic and C# for Excel, PowerPoint, and Word using both editors and it was relatively painless to create them. You can find a link to the Ribbon code snippets and some of the Ribbon customization how-to videos I'm doing on Erika Ehrli's blog at:

Since a lot of the header information of the Ribbon code snippets was the same, I found it easier to create a couple of the basic Ribbon customization snippets using the editors and copy and modify them in NotePad for the majority of the other samples.

Up until I started using code snippets, when I ran across pieces of code that I thought I might use at some later time, I keep them in a folder on my hard drive as a text file. Then in the heat of battle, I'd usually forget that I had the samples and when I did, I had to stop what I was doing in Visual Studio and search through them to find the right one (assuming I had given them a descriptive name).

Code snippets allow you to group similar samples together in a series of folders and then make those folders available right in Visual Studio without having to break your workflow. Just create a link to the folder(s) by clicking Code Snippet Manager on the Tools menu. Then to use, place the curosr in the desired location in the code window, right-click, click Insert Snippet, and the code is dropped into the code. Pretty sweet.

You can find more information about using code snippets in Visual Studio by searching inĀ MSDN and also by searching the Internet.