Search code examples
c#visual-studio-2010code-snippets

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


Is there a way to create a 'surround with' snippet in visual studio 2010? I know how to create a replacement type of snippet. A simple surround with snippet could surround a block of text with an asp:hyperlink. Similar to the way the default 'surround with' snippets can surround a block of code with an asp:panel.


Solution

  • Have a look at the MSDN article on creating snippets. It should give you a good start. When you create your snippet, be sure to give it a SnippetType of SurroundsWith to make the snippet surround selected code.

    For the latest Visual Studio (currently 2017), there's Code Snippets on Microsoft Docs, as well as Walkthrough: Creating a Code Snippet.