How to create a ‘surround with’ type of snippet in Visual Studio 2010?

It turns out that there are some pre-defined ID’s that are not well documented. Specifically For SurroundWith type snippets, there is an ID $selected$. So, for example, the code for the #if snippet is:

...
<Code Language="csharp">
    <![CDATA[#if $expression$ $selected$ $end$ #endif]]>
</Code>
...

The $end$ ID indicates where to place the cursor when the Surround function is complete.
That’s really all there is to it. Of course, remember to include SurroundsWith as the SnippetType

For more examples, try taking a look at the predefined snippets in C:\Program Files\Microsoft Visual Studio 10.0\\Snippets\1033\.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)