Visual Studio Macro to surround a selection with a HTML tag.

In many of our admin websites and web based tools we highlight domain keywords to make them stand out using: 

<span class="keyword"></span>

The problem is, I am always forgetting to do it at the time of writing the content and then need to go back and insert all the spans. This can be a bit of a pain so I have created a Visual Studio Macro to help. 

The code is in the picture below. Posterous ability to display code is a complete joke.

It just replaces the selected text with the selected text turned into proper case and the span class included. Note, I haven't included the closing tag. This is because Visual Studio closes it for you anyway and there's no point working against it by disabling auto complete and then reenabling it again. 

As this is about keywords for me, I have mapped it to ctrl+k when in the HTML Code editor. You can map it to whatever you like though. 






Popular posts from this blog

Follow on from home automation post

Functional Filtering in Javascript

Derbyshire Dot Net Talk - Writing Robust Systems