Customize Visual Studio 2005 Templates for Coding Productivity

My 2-year-old baby boy is a bit under the weather, so we hung out at home while Mom and the girls enjoyed a number of fall activities we had planned this weekend.  One of the tasks he helped me with was downloading and installing the production bits of Visual Studio 2005, etc. on the test machine.  Our first order of business was to better learn the new IDE and make it bend to our will 😉


Visual Studio 2005 Templates

Visual Studio 2005 contains several templates that can be modified for when you add new items to your websites and projects.  In particular, I have always been a bit disappointed by the default Class Template when adding a new C# Class to my projects.  It is quite useless actually, merely providing a default namespace and a minimal class shell named something like Class#.

Visual Studio 2005 has default templates for all the items buried in the %Program Files% directory on your PC.  Luckily for us, we can actually modify these templates if we wish to create a template that is a bit more practical and personable to our liking.  Being a bit of a productivity junkie interested in code generation, O/R Mappers, etc., I decided to play with the Class Template today to make it suit more of my normal Class Environment.

Shown below is a directory tree of the template locations.  Templates are located in *.ZIP files within your ItemTemplates Folder, and a cache of these items are located in the ItemTemplatesCache Folder.  There is also a NewFileItems folder not shown for when you add items via File > New Item.



Modifying the Class Template

To customize the Class Template, modify the Class.cs file ( or the appropriate one for your preferred language ) with the default code that you would like to appear when a class is intially created.  Add all the normal statements, fields, properties, contructors, etc. to this template that you would normally have to type manually.

The templates do have some variable parameters that can be used.  I haven’t dug deep into the list of parameters, but this page will get you started:,vs.80).aspx


I made a few changes to the Class Template as a test to add XML comments; regions for fields, properties, constructors, etc; overrides for ToString(), etc. of Object; and a default constructor.  Later I will fill this out more with a bit more detail.  Shown below is the outlined code view for my practice default template for a C# Class.  Note that all of this is from the customized template.  I typed nothing.




Code Generation and productivity comes in a number of flavors.  The easiest way to increase productivity in your day-to-day programming is to modify the default templates for Visual Studio 2005.  Later I will show you how to create custom templates as well.


DrinkingDragon Well Green Tea


This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

2 Responses to Customize Visual Studio 2005 Templates for Coding Productivity

  1. says:

    Here is a pointer to a blog entry I did on how to do this for web page templates as well:

    Hope this helps,


  2. timh says:

    another method (without altering the base files or creating a new template) would be to leverage the intellisense code snippet features.

    you could start a new class file out of the box type “myclass” and your custom class would be implemented the same as the template.

    just another method using the cool features.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>