Change file templates in VS.Net

If you are like me every time you create a new file in VS.Net you change the way code is arranged or laid out.  Well here is a tip for you. 

Change file templates: Here is how you would change your windows form file template(for C#):

    Open up <VS.NET Install Dir>\VC#\VC#Wizards\CSharpAddWinFormWiz\Templates\1033 directory
    Open NewWinForm.cs
    Make any changes to the template(NewWinForm.cs)
    Special symbols:
    • For the class name use [!output SAFE_CLASS_NAME]
    • For the default namespase use [!output SAFE_NAMESPACE_NAME]
    Once you are done with your changes just save the file and your done (test it when you create a new window form it should use that template)

This same idea should work for any of the file you want to change you just need to figure out the Wizard that is used to create a new file, it is usually pretty ease because they name the Wizard folders with a similar name and the file type (ie CSharpAddWinFormWiz and New Windows form). This should also work for VB just gointo the VB\VBWizards instead of VC#\VC#Wizards.

I hope this helps someone out there.

1 Comment

  • Hey,

    What do you do if you don't have a NewWinForm.cs file? I've searched my entire FS for the templates folder and it doesn't seem to exist, yet I use the templates every day...

    I'm using vs.net 2005, US English installation on a German WinXP, and I can't find this specific directory or any of the mentioned files anywhere :(

Comments have been disabled for this content.