VIM and markdown

Markdown logoå

Markdown (still) is my way to write down these blogg entries.

While I usually use Eclipse to edit the files (simply because the editor is open all the time) I recently started appreciating the Syntax highlighting in VIM. First with Puppet code (that was really(!) nice), then with Markdown…

The installation is quite simple. There are at least three different ways of doing it, depending on what you prefer. Since I’m not so fancy about additional tools and shit, I went for the for the plain installation directly from the tar-ball. That one was easier than expected.

Though there are different implementations for it as well, I went for Plasticboy’s module. As it’s stated in the Readme of the repositiory you

  1. Download the tar-ball

  2. Decompress it into your vim profile folder

    $ cd ~/.vim
    $ wget https://github.com/plasticboy/vim-markdown/archive/master.tar.gz
    $ tar --strip=1 -zxf vim-markdown-master.tar.gz
    

Alternatively we can just get the latest version from the GIT repository:

$ git clone https://github.com/plasticboy/vim-markdown.git
$ cd vim-markdown
$ sudo make install
$ vim-addon-manager install mkd

This markdown support has one negative side: double spaces trailing a line will be displayed in bright yellow. This should work to disable the end-of-line space highlighting when using the plasticboy mkd plugin:

:syn clear mkdLineBreak

This could be dropped into autocmd to avoid doing it manually every time again you load a markdown file. To just turn down the yellow-volume into something softer, we can change the highlighting rule:

:hi link mkdLineBreak Underlined

Also showing them slightly darker or lighter is an option worth to consider, using custom ctermfg, ctermbg, guifg, guibg settings. More information about link highlight groups, enter :help highlight or :help group-name. That will give you a list of groups that can be linked.


For setting the syntax anyway when the file is not recognized automatically:

:set syntax=markdown

Include this into ~/.vimrc to apply it automatically to md-files:

au BufRead,BufNewFile *.md set filetype=markdown