Vim Markdown Preview

At work, we’re recently started to try and be nice people when it comes to repositories. We’ve started leaving more README’s. Also we’ve found that when we’re sending out emails to other people, formatting code is just a pain. It’s usually just little clips here and there. The kind of thing you would put in a stack overflow post, or a github comment.

Markdown is really nice. It’s quick and elegant. There’s even an Outlook plugin, but only if you’re in windows. But if you’re stuck using Outlook for Mac, there’s not really anything for you. That, along with the fact that I really would like to see what my README will look like, lead me to look into a Vim solution.

Vim Instant Markdown


This Vim plugin looks awesome. The Github is here, but unfortunately, the install instructions are a little odd.

To get up and running, you’ll need to have Node.js installed and the Xcode command line tools (or just Ruby). Once you have those run the following commands.

You also need to install the npm  package instant-markdown-d . But right now their package doesn’t work. Download their repo and change the package.json to have

instead of

and then run

If you have Vundle add the following to your vimrc

and then execute  :PluginInstall

Or if you don’t have Vundle, install it or look at the vim-instant-markdown github for install instructions.

Finally, make sure you have  filetype plugin on in your vimrc

Tweaks


When you open something that is recognized as markdown, it opens the preview immediately. If that’s something that annoys you, just throw this in your vimrc

in your vimrc. Then, when you open a markdown file, just run  :InstantMarkdownPreview

Second, if you don’t want it to update the preview in real time add this to your vimrc

so that it only updates when

  • No keys have been pressed for a while
  • A while after you leave insert mode
  • You save the file being edited

Leave a Comment

Your email address will not be published. Required fields are marked *