Syntax highlighting in WordPress using Windows Live Writer
Posted by Vadim on February 24, 2009
We always strive to make our code as readable as possible in our posts. I’ve been searching for the perfect source code plug-in since I started blogging. I finally found the style I like to present my code. It looks like this:
public void Foo() { Console.WriteLine("Where's my code plug-in?"); }You’ve probably seen this style many times before. Until today I had no clue how I can present my code similar to this. It just took a little bit of googling to find out that WordPress allows us to format our code like shown above.
Here’s the syntax we need to use:
[sourcecode language='csharp']
your code here
[/sourcecode]
However, it doesn’t solves my problem completely. I usually create my posts using Windows Live Writer (WLW) and if you try to type the code as above it is not going to look pretty.
So far I found this solution:
1. When pasting code into WLW change to Source view (Shift-F11).
2. Type following:
<pre>[sourcecode language='csharp']
-- You code goes here.
[/sourcecode]</pre>
3. Switch back to Edit view (F11).
Don’t be alarm that your code doesn’t look as expected in Windows Live Writer. It’s going to look right in your WordPress blog.



Jeff Klawiter said
Check out this live writer addon. http://www.codeplex.com/wlwSyntaxHighlighter no need to go into source view and it works with the syntax highlighter you are using on here.
Blogging with MS Live Writer « Corey Coogan said
[...] that shows how to stop LiveWriter from formatting special characters. Next, I used this technique, in which you simple wrap your “sourcecode” tag in a <pre> and then all is [...]
Live Writer syntax highlighting plug-in for Wordpress. « Vadim's Weblog said
[...] by Vadim on February 8, 2010 About a year ago I wrote a small article how to use syntax highlighting in WordPress using Windows Live Writer. Few months ago I discovered Rich Hewlett’s plug-in for Windows Live Writer that [...]
WordPress understands PowerShell « Grimkey Bytes said
[...] of them looked pretty terrible in WordPress. After a little more Bing searching, I discovered: http://vkreynin.wordpress.com/2009/02/24/syntax-highlighting-in-wordpress-using-windows-live-writer/. This allowed me to paste my code in directly as [...]
lmaran said
You can avoid switching between “Edit” and “Source” and eliminate the “pre” tags using the PreCode plugin for WLW (http://precode.codeplex.com/). I used it with the folowing setings:
- Surround With: PRE
- Highlighter Class: None
- All others checkbox: false
…and the code, between [language] attribute.
How to use Syntax Highlighting in WordPress « audministrator said
[...] Source : Syntax-highlighting-in-wordpress [...]