c# - Automatically create #region with same name at #endregion -
i'm wondering if there way make #region region #endregion region
. if there no way doing maybe possible resharper?
hope it's clear i'm trying achive here.
edit:
<?xml version="1.0" encoding="utf-8" ?> <codesnippets xmlns="http://schemas.microsoft.com/visualstudio/2005/codesnippet"> <codesnippet format="1.0.0"> <header> <title>#region</title> <shortcut>#region</shortcut> <description>code snippet #region</description> <author>microsoft corporation</author> <snippettypes> <snippettype>expansion</snippettype> <snippettype>surroundswith</snippettype> </snippettypes> </header> <snippet> <declarations> <literal> <id>name</id> <tooltip>region name</tooltip> <default>myregion</default> </literal> </declarations> <code language="csharp"><![cdata[#region $name$ $selected$ $end$ #endregion $name$]]> </code> </snippet> </codesnippet> </codesnippets>
second edit: it's work when make insert snippet. intellisense using other snippet gues.
so there way add region intellisense not insert snippet menu?
if trying acheive is...
#region myregion //...lots of code... #endregion // end of myregion
you can so-called 'surroundswith' snippet. here such snippet library...
<?xml version="1.0" encoding="utf-8"?> <codesnippet format="1.0.0" xmlns="http://schemas.microsoft.com/visualstudio/2005/codesnippet"> <header> <title>enregions block of code</title> <author>gjv</author> <shortcut>enr</shortcut> <description>surrounds block of code region directives</description> <snippettypes> <snippettype>surroundswith</snippettype> <snippettype>expansion</snippettype> </snippettypes> </header> <snippet> <declarations> <literal editable="true"> <id>regionname</id> <tooltip>region name</tooltip> <default>myregion</default> </literal> </declarations> <code language="csharp"> <![cdata[ #region $regionname$ $end$ $selected$ #endregion // end of $regionname$ ]]> </code> </snippet> </codesnippet>
to use in visual studio, put snippet in .snippet file , save in snippets directory, go tools => code snippets manager => add. once it's added, can use standard ctrk k+x access it.
the thing gives on built-in snippet region flexibility add trailing comment indicate region's end. can further customise adding additional expansions.
note: sentinal $end$ marks want cursor land when operation complete.
Comments
Post a Comment