在Visual Studio中更改默认的XML注释片段
问题描述:
当我在Visual Studio中点击///时,是否可以从中更改结果片段:
When I hit /// in Visual Studio, is it possible to change the resulting snippet from this:
/// <summary>
///
/// </summary>
对此吗?:
/// <summary></summary>
答
以下是至少在VS2010中有效的解决方案.
Here is the solution working in at least VS2010.
将底部代码另存为文件summ.snippet.
Visual Studio 2010/工具/代码段管理器
单击导入,浏览到文件.使用默认选项保存.
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
结果
/// <summary> </summary>
将光标放在标签的中间,可以输入内容.
with the cursor in the middle of the tag, ready to type.
这是summ.snippet的内容
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>