折叠区域中的代码片段
我正在尝试添加代码片段,并且希望此代码出现在某个区域中。所以我在片段文件中尝试了类似的操作。
<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>
但是当我使用代码片段 rg 时,该区域默认显示为展开的,如下所示。
- #region MyRegion
// Some Code
#endregion
有什么办法可以让这个区域像这样默认折叠吗?
+ MyRegion
I am trying to add 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,插入 sippet 操作被视为正常的复制和粘贴操作。因此,我认为不可能插入折叠区域。特别是,VS 需要一些时间才能将其识别为一个区域。
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.
你可以尝试一下这个方法,看看是否有效。
http://www.mikebevers.be /blog/2009/06/visual-studio-custom-region-code-snippet/
You can try this and see if it works.
http://www.mikebevers.be/blog/2009/06/visual-studio-custom-region-code-snippet/