How do I edit the Visual Studio templates for new C# class/interface?
2022
Visual Studio 2022 is now a 64bit process so its location has changed to using Program Files
instead.
%ProgramFiles%\Microsoft Visual Studio\<year>\<edition>\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs
Year | Edition | Absolute path |
---|---|---|
2022 | Community | %ProgramFiles%\Microsoft Visual Studio\2022\Community\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs |
Enterprise | %ProgramFiles%\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs |
|
Professional | %ProgramFiles%\Microsoft Visual Studio\2022\Professional\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs |
2017 through 2019
Visual Studio 2017 changed the directory location to use release year instead of its internal version number, and is additionally dependent on your edition (Professional/Enterprise/etc.):
%ProgramFiles(x86)%\Microsoft Visual Studio <year>\<edition>\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs
Year | Edition | Absolute path |
---|---|---|
2019 | Community | %ProgramFiles(x86)%\Microsoft Visual Studio 2019\Community\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs |
Enterprise | %ProgramFiles(x86)%\Microsoft Visual Studio 2019\Enterprise\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs |
|
Professional | %ProgramFiles(x86)%\Microsoft Visual Studio 2019\Professional\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs |
|
2017 | Community | %ProgramFiles(x86)%\Microsoft Visual Studio 2017\Community\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs |
Enterprise | %ProgramFiles(x86)%\Microsoft Visual Studio 2017\Enterprise\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs |
|
Professional | %ProgramFiles(x86)%\Microsoft Visual Studio 2017\Professional\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs |
2012 through 2015
Starting with VS 2012, the templates are not zipped, so you can edit each .cs template in each applicable folder directly.
%ProgramFiles(x86)%\Microsoft Visual Studio <version>\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs
Year | Version | Absolute path |
---|---|---|
2015 | 14.0 | %ProgramFiles(x86)%\Microsoft Visual Studio 14.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs |
2013 | 12.0 | %ProgramFiles(x86)%\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs |
2012 | 11.0 | %ProgramFiles(x86)%\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplates\CSharp\1033\Class.cs |
2010 and older
Extract, edit and recompress the ZIP file. Paths are for the class template, but interface templates are in the same folder.
You may want to edit the VS template file in each to remove the fact that they don't automatically add references to the assemblies System, System.Data and/or System.Xml.
%ProgramFiles(x86)%\Microsoft Visual Studio <version>\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip
Year | Version | Absolute path |
---|---|---|
2010 | 10.0 | %ProgramFiles(x86)%\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip |
2008 | 9.0 | %ProgramFiles(x86)%\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip |
2005 | 8 | %ProgramFiles(x86)%\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates\CSharp\1033\Class.zip |
Notes
Express Editions
In Express Editions you will have to search in the subdirectory WDExpress
inside the IDE
folder, so e.g. for VS 2015 Express:
%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\Common7\IDE\WDExpress\ItemTemplates\CSharp\Code\1033\Class\Class.cs
Other Languages
If you don't use the English version of Visual Studio, the folder 1033
may not exist, but a different number representing your language. For example it is 1031
in a German installation.
You're looking for the following directory:
C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp
Each template is a ZIP file inside the 1033
(English) subfolder of one of the categories in this folder. You can edit the .cs
file inside the ZIP file.
If you're on a 32bit system, remove the (x86)
. VS2005 is Microsoft Visual Studio 8
, and VS2010 is Microsoft Visual Studio 10.0
.
Note that these templates are not per-user. You can make per-user templates by copying those ZIP files to My Documents\Visual Studio 2008\Templates\ItemTemplates\Visual C#
.