Vim and Markdown are a match made in heaven. I got introduced to Markdown when I first started using Github back in 2010. I like its simplicity. The only problem has been getting Vim to recognize and properly highlight the syntax for it. Here is a way to do that with Vundle, which is a plugin manager for Vim.

Prerequisites

  • Git
  • Curl

Installation

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

Now that we have cloned Vundle, let’s add the text below in our .vimrc so we can start using it. Note: the text below is the bare-minimum to get Vundle working.

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vundle Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim

call vundle#begin()

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

""""" Put your plugins here.

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required

Now that we have the bare minimum, let’s add the Vim Markdown repo inside .vimrc. Add the following right below the text “Put your plugins here”:

Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'

Save and exist .vimrc. Now execute the following on the command line:

vim +PluginInstall +qall

Vim Markdown enables folding by default, which causes sections to be wrapped. Execute the following in normal mode to turn-off folding:

:set nofoldenable

To turn-off folding altogether, add the following at the end of the Vundle settings in your .vimrc:

" Disable folding
let g:vim_markdown_folding_disabled=1

In the end, this is what my .vimrc looks like:

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vundle Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim

call vundle#begin()

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

""""" Put your plugins here.
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required

" disable the folding
let g:vim_markdown_folding_disabled=1

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Basics
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax on

" Tell vim to remember certain things when we exit
"  '10  :  marks will be remembered for up to 10 previously edited files
"  "100 :  will save up to 100 lines for each register
"  :20  :  up to 20 lines of command-line history will be remembered
"  %    :  saves and restores the buffer list
"  n... :  where to save the viminfo files
set viminfo='100,\"100,:20,%,n~/.viminfo

set backspace=eol,indent,start
set autoindent
set history=900

" Stop Vim from beeping all the time.
set vb

set tabstop=2
set shiftwidth=2
set softtabstop=2
set smarttab

set ruler
set background=dark

" Keep it at 80 columns.
au BufRead,BufNewFile *.tex setlocal textwidth=80
au BufRead,BufNewFile *.txt setlocal textwidth=80

" Tell you if you are in insert mode.
set showmode

" Match parenthesis, i.e. ) with (  and } with {.
set showmatch

" Ignore case when doing searches.
set ignorecase

" Tell you how many lines have been changed.
set report=0

" Uncomment to insert spaces instead of a tab when tab is pressed.
set expandtab

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Paste
" :help paste recommends F10 and F11, but this is hard on Mac keyboard.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <F5> :set paste<CR>
map <F6> :set nopaste<CR>
imap <F5> <C-O>:set paste<CR>
imap <F6> <nop>
set pastetoggle=<F6>

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Drupal
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Drupal command group, set the correct filetypes for Drupal files.
augroup drupal
  autocmd BufRead,BufNewFile *.module set filetype=php
  autocmd BufRead,BufNewFile *.theme set filetype=php
  autocmd BufRead,BufNewFile *.inc set filetype=php
  autocmd BufRead,BufNewFile *.install set filetype=php
  autocmd BufRead,BufNewFile *.info set filetype=php
  autocmd BufRead,BufNewFile *.engine set filetype=php
  autocmd BufRead,BufNewFile *.profile set filetype=php
  autocmd BufRead,BufNewFile *.test set filetype=php
augroup END

Resources