Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change default XML comment snippet in Visual Studio

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

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

to this?:

/// <summary></summary> 
like image 559
Daniel Schaffer Avatar asked Dec 15 '08 17:12

Daniel Schaffer


People also ask

How do I change code snippets Visual Studio code?

To create or edit your own snippets, select User Snippets under File > Preferences (Code > Preferences on macOS), and then select the language (by language identifier) for which the snippets should appear, or the New Global Snippets file option if they should appear for all languages.

How do you put comments in XML?

An XML comment encountered outside the document type declaration is represented by the Comment value syntax element. It contains the comment text from the XML message. If the value of the element contains the character sequence --> , the sequence is replaced with the text --&gt; .

What is XML snippet?

The XML editor offers a feature, called XML snippets, that allows you to build XML files more quickly. You can reuse XML snippets by inserting them into your files. You can also generate XML data based on an XML schema definition language (XSD) schema.


2 Answers

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> 
like image 114
Valamas Avatar answered Oct 06 '22 20:10

Valamas


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

like image 44
Mark.Goldberg Avatar answered Oct 06 '22 20:10

Mark.Goldberg