When I was using dasBlog as my blogging engine, copying code snippet into blog posts seemed to be almost as easy as copy and paste. The only problem was that depending on which program was used to display the code, the resulting HTML could be ugly and highly bloated. And sometimes it is quite difficult to edit the pasted code snippet within dasBlog. Nevertheless, copy and paste worked there.
After I switched to WordPress, I found that incorporating code in posts can be extremely challenging without using any plugins. The problem seemed to have come from WordPress itself as it tries to interpret what was in the post and tries to adjust tags if necessary to make sure that they match. But this "smart" behavior has caused much trouble for pasting from programs such as MS Word. Most of the times, the resulting HTML would not work and sometimes it would even mess up the web page itself.
There are quite a few WordPress plugins out there that helps making displaying code easier within WordPress. The majority of them does so by formatting the code pasted within a <pre> tag. Nevertheless, this is still not as easy as pasting directly from an IDE like Visual Studio .Net.
Fortunately, CopySourceAsHtml comes to the rescue. This is a neat little Visual Studio .Net (works for both 2003 and 2005) plugin that allows copying source code as HTML formated contents and place it in the clipboard. So when pasted into a WordPress editor, it was only the plain HTML. It works quite nicely. Here is an example:
using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication1{class Program{static void Main(string[] args){Console.WriteLine("Hello World");}}}
The only drawback is that it only supports Microsoft Visual Studio .Net environment. Of course, someone could always create such plugins for other environments if he wishes to.