Visual Studio Add-Ins: Copy Source as HTML

Our next tool is very handy for those of us who blog, or perhaps just want to share code snippets with friends using HTML enabled e-mail. Copy Source as HTML, available at does just what it says. It takes the lines of source code you have highlighted in your Visual Studio editor and copies them to the clipboard as HTML.

For an example, I’ve pasted this simple HTML into my blog so you can see what it looks like. This is HTML text, not a picture:


    9 namespace WinTest1

   10 {

   11     public partial class Form1 : Form

   12     {

   13         public Form1()

   14         {

   15             InitializeComponent();

   16         }

   17     }

   18 }



There are several options, as you can see from the dialog below.

[Copy Source as HTML Options Dialog]

You can have line numbers (as I’ve done above), set the line number to start at, or omit them entirely. You can activate word wrap, over ride the default tab size, font and font size. If you’re a CSS guru there are even tabs for entering your own CSS for both the entire section (surrounded in DIV tags) or the individual line.

Another great free add-in, it has both 2005 and 2003 versions. If you ever need to convert your code to HTML this is a great, easy way to do it.