I am trying to ad开发者_C百科d a code snippet and I want this code to appear in a region. So I tried something like this in the snippet file.
<CodeSnippets
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>
rg
Code Snippet for Region
</Title>
<Shortcut>rg</Shortcut>
</Header>
<Snippet>
<References>
<Reference>
<Assembly>System.dll</Assembly>
</Reference>
</References>
<Code Language="CSharp">
<![CDATA[
#region MyRegion
// Some Code
#endregion
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
But when I use the code snippet rg, the region appears as expanded by default like this.
- #region MyRegion
// Some Code
#endregion
Is there any way I can get this region as collapsed by default like this?
+ MyRegion
As far as I know, the insert sippet operation is treated like a normal copy and paste operation. Therefore, I would assume that it is not possible to insert a collapsed region. Especially, as it takes VS some time to recognize it as a region.
<![CDATA[
#region $RegionName$
$selected$ $end$
#endregion
]]>
You can try this and see if it works.
http://www.mikebevers.be/blog/2009/06/visual-studio-custom-region-code-snippet/
精彩评论