Last Updated: March 02, 2016
·
8.417K
· tylerhunt

Markdown with Fenced Code Blocks in Vim

Enable syntax highlighting within fenced code blocks in Markdown documents in Vim:

  1. Install the latest version of the vim-markdown plugin. If you have pathogen.vim installed, this is as simple as:

    cd ~/.vim/bundle
    git clone git@github.com:tpope/vim-markdown.git
  2. Add this to your ~/.vimrc:

    " Markdown
    let g:markdown_fenced_languages = ['coffee', 'css', 'erb=eruby', 'javascript', 'js=javascript', 'json=javascript', 'ruby', 'sass', 'xml']
  3. Modify the list to add any other languages you use in your Markdown documents. You can use mappings like js=javascript to map between the language name in the code block (js) and the filetype name used by Vim (javascript). See the Linguist library for the full list of languages supported by GitHub.

2 Responses
Add your response

This is great. Thanks!

over 1 year ago ·

Thanks ! Exactly what I was looking for.

over 1 year ago ·