28

When I hit /// in Visual Studio, is it possible to change the resulting snippet from this:

/// <summary>
/// 
/// </summary>

to this?:

/// <summary></summary>
Mihai Limbășan
  • 64,368
  • 4
  • 48
  • 59
Daniel Schaffer
  • 56,753
  • 31
  • 116
  • 165
  • 2
    Reading this question in 2019, it is misleading because since VS2015(?) `///` does not simply print `/// ` but also template elements for each parameter, generic type, and return value. If you are looking for that kind of customization keep on searching... – Jack Miller Jul 10 '19 at 06:51

3 Answers3

17

Here is the solution working in at least VS2010.

Save the bottom code as a file summ.snippet.
Visual Studio 2010 / Tools / Code Snippet Manager
Click import, browse to file. Save with default options.

Now goto your code window and type summ + tab + tab

Result

/// <summary>  </summary>

with the cursor in the middle of the tag, ready to type.

Here is the contents of the summ.snippet

<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">

    <CodeSnippet Format="1.0.0">
        <Header>
                <Title>Summary - inline</Title>
                <Description>Created inline summary comment tag</Description>
                <Author>Mike Vanderkley</Author>
                <Shortcut>summ</Shortcut>
                <SnippetTypes>
                        <SnippetType>Expansion</SnippetType>
                </SnippetTypes>
        </Header>
        <Snippet>
            <Code Language="csharp">
                <![CDATA[/// <summary> $end$ </summary>]]>
            </Code>
    </Snippet>
  </CodeSnippet>

</CodeSnippets>
Valamas
  • 24,169
  • 25
  • 107
  • 177
  • Clever! I'd still prefer to be able to use the standard `///` shortcut, but this is far better than clearing up the linebreaks manually. – Daniel Schaffer Apr 07 '11 at 00:44
  • The `summ` keyword starts to work after a while and you will forget all about the `///`. I noticed that some of the attributes were missing having pasted in stackexchange. The version showing is now the correct version. Recommend re-importing and overwriting the old version. – Valamas Apr 07 '11 at 01:02
  • This still works (VS2015). Changed xmlns 2005 to 2015. Also works in vb changing /// to ''' and "csharp" to "vb". Thanks – Word Rearranger Apr 05 '18 at 14:15
9

It appears to me that what the /// generates is coded in: Macros.Samples.Utilities.InsertDocComments

Mark.Goldberg
  • 91
  • 1
  • 1
4

I know that it was possible for VB in VS 2005 and VS 2008. Last I had checked, though, there was not a way to do it for C#, sadly. That has been a pet peeve of mine for some time, now.

Joseph Ferris
  • 12,576
  • 3
  • 46
  • 72
  • Sadly, it has become a habit of mine to just go in and change it when it is inserted. It is almost like I do it on autopilot now. Not sure if any third-party apps or add-ins address this or not. – Joseph Ferris Dec 15 '08 at 19:07
  • Yeah, I've been doing it manually, and I don't want to run a 3rd party app or add-in just for this. Thanks! – Daniel Schaffer Dec 15 '08 at 19:48
  • 1
    How do you do this in VB? [This question](http://stackoverflow.com/questions/1610318/vb-net-automatic-xml-comments-can-i-change-the-automatic-defaults) wants to know. – Mark Hurd Aug 13 '10 at 16:42