Yan Pritzker software entrepreneur, photographer, musician

Blog :: Git Workflows Book :: Dotfiles :: Photography :: About Me

Get the news feed
Get updates by email
Follow me on twitter

hello, i'm yan

I am a photographer, entrepreneur, technologist, guitarist, climber, and telemark skier

This blog is about startups, blogging, Ruby On Rails, virtualization and cloud computing, photography, customer service, marketing, ux and design, git, and lots more.

I am the CTO at Reverb.com - The Marketplace for Musicians. We're hiring web Ruby and iOS developers!

Selected Reading



Reach me at yan at pritzker.ws

Stop using colon commands in vim

Posted 30 May 2012 @ 11am in vim

Time for another vim geekout! :)

Typing colon :commands is really slow. You have to hit shift, colon, command, plus enter to execute. You’re taking a 3 keypress overhead every time you use one. So what to do? Simplify your life with a three tiered approach

  1. Super common things should be chords (Ctrl-something, Cmd-something, Cmd-Shift-something) or single key presses.
  2. Second most common things should be two character mnemonics such as vv
  3. Third tier should be leader-based commands with two or three keys such as ,gg for GitGrep in my setup

For example, the normal way to go to a tab is :tabn which is at least 7 keypresses. A much better way is to map all your tabs to Cmd-1 through Cmd-9 and jump instantly to them with a single chord (This if for MacVim, you can map another key if you need unix)

map <silent> <D-1> :tabn 1<cr>

What about jumping between windows? The standard vim way will have you doing a chord and then a key (C-w, l) to get to the right. Remap to a two-key chord:

nnoremap <silent> <C-l> <C-w>l

Closing windows? Normally you’re stuck with :bd for 5 key presses to kill a buffer or C-w, c – a chord and a key (3 slow keys). I kill windows all the time, so for me it’s just the letter Q – a simple chord. And I made it smart enough to kill either the window or the buffer, using a script that figures out if there are any other windows into the same buffer.

What about splits? Same deal..way too many keys. Type a two key mnemonic vv for a vertical split:

nnoremap <silent> vv <C-w>v

I usually grep for things all day long so I mapped a single key K to give me the git grep for the current word under the cursor:

nnoremap <silent> K :GitGrep <cword><CR>

My rule is to really consider every time I type more than 3 keys to execute a command in vim, and if it’s something I do every day, remap, remap, remap!

If you liked this, please take a look at my YADR dotfiles project – which has many more interesting keymappings to save you time, and has recently broken 700 watchers on GitHub!