Monday, April 12, 2010

My Vim Configuration

I've posted a number of articles on configuring Vim, and a few readers have asked me to post my complete .vimrc file.

My configuration includes:

So, without further ado.
" VIM Configuration - Mohit Muthanna

" Enable syntax highlighting.
syntax on

" Do awesome stuff on MacVim
if has("gui_macvim")
" Disable toolbar on MacVim
set go-=T

" MacVim font and color scheme
set guifont=Inconsolata:h13
colorscheme torte

" Enable spell checking. For source code, it only checks comments.
" set spell spelllang=en_us

" Set title on X window
set title

" Hide buffer instead of abandoning when unloading
set hidden ruler wmnu

" Set GUI font and options
" set guifont=Monospace 8
" set guioptions=agimrLt
" set imi=0

" I'm usually on a light-on-dark terminal
set background=dark

" Live incremental search
set incsearch

" Highlight current line (Vim 7)
" set cursorline

" Tabs and indentation. Yes, I like 2-space tabs.
set tabstop=2
set shiftwidth=2
set expandtab
set autoindent
filetype indent on

" Allow extended digraphs
set encoding=utf-8

" Show status line (help statusline)
set statusline=%<%2*%f%h%1*%m%2*%r%h%w%y\ %*%{&ff}\ %=\ col:%c%V\ asc:%B\ pos:%o\ lin:%l\,%L\ %P
set laststatus=2

" Set status line colors
highlight ModeMsg cterm=bold ctermfg=cyan ctermbg=black
highlight StatusLine cterm=bold ctermfg=brown ctermbg=blue
highlight StatusLineNC cterm=bold ctermfg=black ctermbg=green

" Filename in white.
highlight User2 cterm=bold ctermfg=gray ctermbg=blue

" Modified flag on statusline.
highlight User1 ctermfg=red ctermbg=blue

" Highlight trailing whitespace and tab characters. Note that the foreground
" colors are overridden here, so this only works with the "set list" settings
" below.
autocmd ColorScheme * highlight ExtraWhitespace ctermfg=red guifg=red
highlight ExtraWhitespace ctermfg=red guifg=red cterm=bold gui=bold
match ExtraWhitespace /\s\+$\|\t/

" Show tabs and trailing spaces.
" Ctrl-K >> for »
" Ctrl-K .M for ·
" Ctrk-K 0M for ●
" Ctrk-K sB for ▪
" (use :dig for list of digraphs)
set list listchars=tab:»»,trail:·

" I like to stick to lines under 80 columns
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)

" Enable folding by indentation
" Use: zc, zo, zC, zO, zR, zM
" Ctrl-K .3 for ⋯
set foldmethod=indent
highlight Folded ctermfg=red
highlight FoldColumn ctermfg=white
set fillchars=fold:⋯

" My information
iab xdate =strftime("%Y/%m/%d %H:%M:%S")
iab xname Mohit Muthanna Cheppudira
iab xsigp Mohit Muthanna Cheppudira 
iab xsigw Mohit Muthanna Cheppudira 

" Strip trailing whitespace in whole file
func! StripTrailingWS()
command! StripTrailingWS call StripTrailingWS()

This file is continually evolving, and you can always get the latest version here: .vimrc.


  1. Friggin awesome idea dude! I know several BIG websites that could look at this for use eventually. Can't wait to see what you come up with next.

    I'm no coder (I am a win sysadmin though), but you need another set of musical eyes for something, I've nearly 30 years classical experience and training. Just hit me up.