You may have seen that I sometimes post code here. Wouldn't it be nice if all the code are syntax highlighted, like what we see in a text editor? Well, with the help of Vim, it's easy. Vim is bundled with a "2html" script, that can turn whatever shown in Vim into a HTML file, with all it's color and format. To invoke this command, simply issue ":so \$VIMRUNTIME/syntax/2html.vim" command in Vim to run the script. No, you don't have to type this many characters, autocompletion should do most of the typing for you. Vim will then open up a window that contains the newly converted HTML file. If I want to post it to Drupal, I simply remove the unnecessary tags such as "html", "body" and "head", etc. and save the file. When I write the blog entry, I read back the file and insert it where I want it. Also, I enclose the code with
<div class="codeblock">
code here
</div>
so the default Drupal style sheet renders the code within a nice box and on a light gray background. Continue reading »
Recent comments
20 weeks 5 days ago
21 weeks 1 day ago
22 weeks 4 days ago
22 weeks 4 days ago
23 weeks 2 days ago
23 weeks 2 days ago
24 weeks 3 days ago
24 weeks 5 days ago
25 weeks 3 days ago
25 weeks 3 days ago