Many folks are bashing VS2005 but there are some really great things the folks at MS have added for us in VS2005. One of my personal favorites is the code snippets mechanism. I personally find this feature to be kind of underestimated and will try to give you some basic knowledge about what code snippets in VS2005 are, how to manage them, how to find new, and of course how to “do it yourself”
By definition code snippets are referred to as “ IntelliSense Code Snippets” – by nature they are reusable, task-oriented blocks of code, encapsulated in a XML file with a specific format. Visual Studio 2005 includes code snippets that cover broad range of tasks
ranging from creating a custom exception, to drawing a circle, to refactoring the written code (yes, to my surprise the refactoring is organized into code snippets too). A set of Visual Basic and Visual C# Code Snippets are included in the Visual Studio 2005 box – additional Code Snippets can be found at http://msdn.microsoft.com/vstudio/downloads/codesnippets/default.aspx
How to get started with code snippets?
After selecting the desired category at the above-mentioned URL and accepting the Microsoft Permissive License, the browser prompts to download the Visual Studio Community Content Installer file.
The small application that is downloaded and executed, installs the desired code snippets, using a wizard-like procedure:
- First select which code snippets will be installed
- Then the next step is to select the code snippets and their location on your local disk (the snippets are contained in special code snippet directories, managed by VS2005)
All the management, including adding new snippets directories to the search path is managed through the Code Snippets Manager. More information on Code Snippets Manager could be found at: http://msdn2.microsoft.com/en-us/library/wy5tazc9.aspx
Everything on Code Snippets management is at http://msdn2.microsoft.com/en-us/library/9ybhaktf.aspx. Also don’t miss the Best Practices for Using IntelliSense Code Snippets.
In part two I will demonstrate how to create a simple code snippet that helps writing code for r.a.d.grid's custom CommandItem feature...
Subscribe to be the first to get our expert-written articles and tutorials for developers!