Markdown with Fenced Code Blocks in Vim
Enable syntax highlighting within fenced code blocks in Markdown documents in Vim:
-
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
-
Add this to your
~/.vimrc
:" Markdown let g:markdown_fenced_languages = ['coffee', 'css', 'erb=eruby', 'javascript', 'js=javascript', 'json=javascript', 'ruby', 'sass', 'xml']
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 thefiletype
name used by Vim (javascript
). See the Linguist library for the full list of languages supported by GitHub.
Written by Tyler Hunt
Related protips
2 Responses
This is great. Thanks!
over 1 year ago
·
Thanks ! Exactly what I was looking for.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#