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.


