Change default XML comment snippet in Visual Studio

前提是你 提交于 2019-11-26 18:17:55

问题


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

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

to this?:

/// <summary></summary>

回答1:


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>



回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/369116/change-default-xml-comment-snippet-in-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!