Vim - My .vimrc Highlights

Moving from TextMate to Vim is probably the most significant change I've made to my daily development over the last year - and I'm amazed by how much difference it's made. A few weeks back though this blog post convinced me to go one step further - I took a deep breath and deleted my entire vim install.

Starting over

Following Mislav's advice, I started out with 13 lines of simple configuration, initially adding only pathogen, the vim-rails plugin and the truly awesome solarized theme. With those staples in place I left my .vimrc file open, made friends with :source $MYVIMRC and resolved to only add a mapping or plugin if my workflow depended on it. Two weeks later I can safely say this is the best thing I've done since switching to vim, so here are the highlights from my configuration.

Fuzz Face

Command-T is often suggested as the drop-in vim replacement for TextMate's popular fuzzy finder functionality, but I heartily recommend the far superior ctrlp. The speed alone is worth the switch, but once you add in regexp mode, the ability to jump directly to a line number, and multiple file opening, Command-T is firmly outclassed.

Force yourself

Between gvim and arrow keys I've been cheating for a while, nothing has forced me into dropping some bad habits than locking the arrow keys.

map <Left> :echo 'damnit!'<cr>
map <Right> :echo 'you suck!'<cr>
map <Up> :echo 'this is why you fail'<cr>
map <Down> :echo 'nooooo!'<cr>

Split panes and tabs

I love split panes, this feature was the main reason I left TextMate in the first place. Opening a split pane and jumping into it is an essential shortcut, quite often followed up with vim-rails' :A

map :vs :vsplit<cr><c-w>l

And some shortcuts to resize the split.

" Resize windows quickly
" reset with <c-w>=
nmap <c-w>l :vertical res +20<cr>
nmap <c-w>h :vertical res -20<cr>
nmap <c-w>j :res +20<cr>
nmap <c-w>k :res -20<cr>

Whilst I tend not to use tabs as often as I use buffers, I still enjoying being able to flip between tabs quickly when I do.

nmap <leader>[ :tabprevious<cr>
nmap <leader>] :tabNext<cr>
nmap T :tabnew<cr>

Scratch buffer

With the help of the scratch plugin this gives me a quick split for random notes, something I use all the time.

nmap <leader>; :Sscratch<cr>

And more

In addition to these mappings I've borrowed Gary Bernhardt's testing functions and really cool shortcuts to scroll the other split window.

Feel free to take my vim for a spin, the vimrc is pretty well documented.

git clone git://github.com/seenmyfate/vim.git ~/.vim
cd ~/.vim && rake