Add default formatting to new classes

Is there a way to set up the IDE to include some default comments / formatting when a new class is created


Answer this question

Add default formatting to new classes

  • RyanAustin

    My version of VS .net (2005) seems to be using C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates\CSharp\1033\Class.zip.

    Is there a way to modify this

  • vbuser1

    This officially SUCK!!!! Why the H*** is it so hard to setup templates

    I attempted to create a template for C# class files.

    I created a new class called Class.cs.
    I exported it then copied the .zip file into the two locations specified.
    When I attempt to create a new class file I get the following error:
    Could not find a part of the path 'C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ItemTemplatesCache\CSharp\1033\Class.zip\Class.vstemplate.

    I attempted copying the file from the old zip into my new zip. Same result.
    I attempted to rename the tempate file in my new zip. Same result.

    Did I mention that this sucks!

  • Jith

    It is possible by creating addin for the Visual studio IDE,

    using addin we can control the operation's of IDE

    for more information on addin please look these link

    http://www.c-sharpcorner.com/Code/2002/Oct/AddIns.asp

    http://msdn2.microsoft.com/en-us/library/5abkeks7(VS.80).aspx



  • NoviceDotnetter

    Great. Thanks.

  • Deimos33

    Hi!

    Go to the C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\NewFileItems and edit there CSharpClass.cs. Also you can edit them in this folders:

    C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ProjectTemplates

    D:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates


    And you can always create your class and "Export Template" from "File" menu.


  • mdavison

    Yes, it's usual ZIP archive with templates. But VS2005 also use Cache folder - so you need update both places. Actually I prefer to create new templates by myself, just use "Export template" in File menu. This is convenient, when you reinstall/repair/add/remove VS features - you need to do all work again if you change original files, but if you create own - all much easier.


    Cache folder is C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ItemTemplatesCache


  • buckeye72

    Oh. Got it. I didn't see that new My Templates section of the Add New Item dialog.
    Thanks.

  • doublezen

    I just tried to create MyClass.cs with MyClass class. Then "File\Export template". I select Project Item, select MyClass.cs, enter exported item name & description, leave check box "Import in VS" and all works.

    Why you need copy ZIP You must simply follow wizard and nothing more. Work with ZIP is for changing existing templates, but in "Export template" you don't need it. The only flaw in this export features is that add new item dialog display them at the bottom of the list, not seen after I opened this box, I have to scroll line down.


  • Add default formatting to new classes