I find myself removing the following import statements in nearly every C# file I create in Visual Studio:
using System.Collections.Generic;
using System.Linq;
using System.Text;
Of course its really easy to do this with Resharper, but I really should not have to.
There must be a few template (class, interface) somewhere in the VS directory, from which I can remove the offending lines. Where do I find these files? Is there a better way to control the default import list?
Best Answer
2017 through 2019 (current)
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 2019\Community\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs
%ProgramFiles(x86)%\Microsoft Visual Studio 2019\Enterprise\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs
%ProgramFiles(x86)%\Microsoft Visual Studio 2019\Professional\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs
%ProgramFiles(x86)%\Microsoft Visual Studio 2017\Community\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs
%ProgramFiles(x86)%\Microsoft Visual Studio 2017\Enterprise\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs
%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 14.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs
%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs
%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 10.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip
%ProgramFiles(x86)%\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip
%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 theIDE
folder, so e.g. for VS 2015 Express: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 is1031
in a German installation.