Microsoft 9GD00001 ユーザーズマニュアル

ページ / 449
 
Chapter 12:  Customizing the Development Environment 
353
including CSharp VisualBasic, Web, and more, each folder corresponding to folders in the 
VS New Item window. Under each folder is a locale code—for instance, English is 1033—
and you would copy the file into the locale folder for the category you wanted the project 
template to appear in.
Unlike templates in the local item templates folder, where all you need to do is copy 
the file, item templates in the global item templates folder don’t automatically show up. 
To test the global item templates scenario, you should remove the item template from 
your local item templates folder. You must close down VS and execute the following in a 
command window, which you should open by selecting Start | All Programs | Microsoft 
Visual Studio 2010 | Visual Studio Tools | right-click Visual Studio Command Prompt 
(2010) and select Run As Administrator. This will take a few minutes to run, but afterward 
you’ll see the project appear in the VS New Item window. This command imports all of 
the item templates from the global item templates folder into VS:
devenv /installvstemplates
If later you decide you don’t want a given template to appear in the VS New Item 
window, remove the item template from the global item templates folder(s) and run the 
preceding command again.
This section showed you how to add new project and item templates to VS, but 
sometimes you just want to add a common bit of code while you’re programming. The 
next section shows you how to add your own custom code snippets to VS.
Creating Custom Snippets
If you’ve been using VS snippets, as described in Chapter 2, you’ll know how much time 
they can save when writing common blocks of code. In time, you’ll wonder why certain 
items aren’t already covered by snippets, especially if you’re a C# developer who has 
noticed that VB has many more snippets. Even if you’re a VB developer with the plethora 
of available snippets, you might find blocks of code that will make you more productive 
when written in the form of a snippet. This chapter takes you to the next level in working 
with snippets by showing you how to create and manage your own snippets.
Creating a New Snippet
VB already has a snippet for Sub and Function, but C# doesn’t. Since C# doesn’t have as 
many snippets as VB, I’ll show you how to create a snippet in C#, but the process is similar 
for a VB snippet. To create a new snippet, you can either work from an existing snippet file 
or start from scratch. I’ll show you how to find and open existing snippets first.