Update - I was able to get backtick code blocks working much
better, and made a stab at the YAML Front Matter, but it doesn’t seem to work
syntax include. See the git repo for the updated source.
I use Vim as my day-to-day, non-IDE text editor. Yeah, I know everyone is in love with Notepad2, Notepad+ or whatever the new favorite on the block is. I’ve been a vi/vim guy for ages and am not gonna change.
Since switching my blog to Octopress, I’ve been writing all my posts in Vim. Vim does a nice job with Markdown, but it doesn’t know anything about the other things that are often used in a Jekyll markdown file.
The two big things are:
- It gets confused by the YAML Front Matter
- It can go nuts over some of the Liquid filters and tags
Fortunately Vim has a nice way of letting you add new things to an existing
syntax definition. You just create another syntax file and put it in the
after directory in your
~/.vim directory. Then you just add the new syntax
descriptors and restart Vim.
For the first problem, I found a blog post by Christopher Sexton that had a nice regex match for the YAML Front Matter. He has it included in his Jekyll.vim plugin (which I don’t use, but it is pretty cool).
A quick catch-all regex for Liquid tags and another for backtick code blocks and it works pretty damn well.
Here’s the code:
1 2 3 4 5 6 7 8
I do think it would be cool if I could do a few other things:
- Build in understanding of the Octopress codeblock tag and disable Markdown syntax processing within it.
It also has a three line ftplugin tweak to force markdown files to use expandtab and use a 3 character tabstop. Since I typically keep tabs (I don’t have expandtab in my vimrc) and since Markdown actually uses the spaces to mean things, this just works better. If you don’t like that part, just delete the file.
If you want to use it, I recommend using pathogen and then clone the GitHub repository into your bundle folder.