Use vim's :make to preview Markdown
As it becomes more painful to use a pointing device for long periods of time, I find myself using vim more and so I’m paying more attention to customisation so that the things I’m used to from Sublime Text are available to me.
One thing I’m used to is that when I run the build command on a Markdown file, I expect Marked for Mac to open and render the file that I’m writing. Vim has :make which by default runs make and is mapped to cmd+b on MacVim, so I just needed to reconfigure that command to do the right thing.
The easiest way to do this is via a file type plugin. These are files that live in ~/.vim/ftplugin and are named after the file type. In this case, the file is markdown.vim. The commands inside the file are then available whenever you’re editing a file of that type. (You can use :set ft? to find out the file type of the current file.)
To configure what :make does, we set the makeprg setting like this:
set makeprg=open\ -a\ Marked\\\ 2.app\ '%:p'
Note that spaces need to be escaped for vim and then the space in “Marked 2.app” needs escaping for the shell, which is why there are three \s in a row.
Add this line to ~/.vim/ftplugin/markdown.vim and :make now opens Marked and life is just that little bit easier…
Obviously, if you’re not on a Mac or use a different tool to preview Markdown, then configure appropriately!