I was asked how do I format code for blog posts. Well, to be honest, most of the code that I write in blog posts (and forum posts) are written on the fly, hence the formatting is also done on the fly. However, when I do come to copying and pasting code, I follow these steps:
- Copy the code into notepad.
- Copy the tab character into the clipboard.
- Do a find/replace and paste the tab character from the clipboard for the “find” field. It should appear as a square box.
- In the “replace with” field, I then place three spaces. Then hit the magic replace all button.
- Cut and paste into the blog entry.