VS - How to create a surround-with code snippet

How to create a Visual Studio Surround With code snippet for html:



Visual Studio
Tools ... Code Snippets Manager ... Import ... [filename.snippet]

The snippet file is copied to your Documents directory:

  C:\Users\Richard\Documents\Visual Studio 2013\Code Snippets\Visual Web Developer\My HTML Snippets\html-para.snippet

Tokens used in this script:
  • $end$ marks where to put the cursor after the snippet has run.
  • $selected$ is the selected text prior to running the snippet.


  <?xml version="1.0" encoding="utf-8" ?>
  <CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
      <CodeSnippet Format="1.0.0">
              <Shortcut>para</Shortcut> <!-- type para and press TAB to insert snippet -->
              <Description>Insert HTML p element</Description>
              <Code Language="html"> <!-- begin code here -->
              </Code> <!-- end code here -->

3 ways to use the code snippet:
  1. Type para (the ShortcutText). Press [TAB]
  2. Control+K+X (Insert Snippet) ... My HTML Snippets ... para. Press [TAB or Enter]
  3. Control+K+S (Surround With) ... My HTML Snippets ... para. Press [TAB or Enter]

Ads by Google

Ask a question, send a comment, or report a problem - click here to contact me.

© Richard McGrath