I know this is old and you have probably found the answer by now but I would just like to add for the sake of those who might not know it that this is possible in VS 2010:
- Select the code you would like to surround.
- Do
ctrl-k
ctrl-s
(or right-click and select Surround with...
.
- There are a variety of HTML snippets to choose from.
You can create your own SurroundsWith snippets if you do not find what you are looking for:
- Click
File
and then click New
, and choose a file type of XML
.
- On the
File
menu, click Save
.
- In the
Save as
box, select All Files (*.*)
.
- In the
File name
box, enter a file name with the .snippet
file name extension.
- Click
Save
.
Enter something like the following sample in the XML file:
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>ul-div</Title>
<Author>Microsoft Corporation</Author>
<Shortcut>ul>li</Shortcut>
<Description>Wrap in a ul and then an li</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>selected</ID>
<ToolTip>content</ToolTip>
<Default>content</Default>
</Literal>
</Declarations>
<Code Language="html"><![CDATA[<ul><li>$selected$</li></ul>$end$]]></Code>
</Snippet>
</CodeSnippet>
- Open
Tools
> Code Snippets Manager
.
- Click
Import
and browse to the snippet you just created.
- Check
My HTML Snippets
and click Finish
and then OK
.
You will then have your shiny new HTML snippet available for wrapping stuff in!