
354Microsoft Visual Studio 2010: A Beginner’s Guide
Examining Existing Snippets
Snippets that ship with VS are located at \Program Files\Microsoft Visual Studio 10.0 under a folder for the language (VC#, VB, XML, and more) you need to find a snippet for. There, you’ll either find one or more folders named with language codes (English is 1033) or a folder named Snippets. For some languages, the language code is at a higher level and the Snippets folder is under that or vice versa; regardless, you’ll be looking for the Snippets folder that contains items with a .snippet file extension. The file path for C# is \Program Files\Microsoft Visual Studio 10.0\VC#\Snippets\1033. Beneath the Snippets folder, you’ll see additional folders that serve to categorize other snippets.
We’re going to open the for snippet because it contains several features that give
you a good idea of how snippets work. It might help if you open a blank file by pressing
The .snippet extension is registered with VS, so you can
Listing 12-1 Inside the for snippet
<?xml version="1.0"
<CodeSnippet Format="1.0.0"> <Header>
<Title>for</Title>
<Shortcut>for</Shortcut>
<Description>Code snippet for 'for' loop</Description> <Author>Microsoft Corporation</Author> <SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>index</ID>
<Default>i</Default>
<ToolTip>Index</ToolTip>
</Literal>