Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Notes from "Write code faster: expert-level vim" (given at RailsConf 2010)
Branch: master
Pull request Compare This branch is 12 commits behind r00k:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


FIRST: If you liked my talk, you'll probably dig my screencast: Vim for Rails Developers

Check it out here:

SECOND: If you're in or near Boston, I'm giving a vim training on June 25th

Check it out here:

FINALLY: check out the notes below (and thanks for coming to the talk!)

Fundamental techniques for mastering vim:

First: Reading the freakin' manual

vim is the best-documented open source tool I've ever used
a ton of effort has gone into the help
the ROI is high
two problems:
  it takes some practice
  you're gonna forget what you read

Second: Keep a cheat sheet on your desk

learning vim is a process of accretion
gradually increase by the steady addition of smaller parts
the only way to become an expert is by steadily learning commands
the best way to learn lots of commands is by focusing on a few at a time
keep your eyes open for chances to use the command
to build muscle memory, you must use it in practice
i'll back up

Third: Keep a tool sharpening list

annoyances and inefficiencies
:Q bound to :q example (question, show of hands)
slowly sanding down the rough edges in your environment
Don't break your flow, come back to it
Put it on the back of your cheat sheet

Fourth: Learn all the single-letter commands

Pareto or 80/20
quiz yourself: what does t do? capital t? semicolon?
graphical cheat sheet:

Bonus: stay on the home row

don't use the arrow keys -- quit cold turkey; it's my one wish
don't use escape (can use C-[)

If you do these five fundamental things, you are well on your way to vim mastery. IF you fall asleep now, you'll have already seen the most-important stuff. After these, the rest of what I'm going to show you is just gravy. But sometimes the gravy is the best part, so let's dig in.

Total noob? Use vimtutor.

Discuss the layout of the rest of the talk.


two most-important commands
:h buffers
recommend Editing Effectively
what if you don't know what you want? tab complete and C-d
#vim on freenode
vimtips wiki:
life, the universe, and everything = 42


  named with " and a letter/number
  1-9 hold last 9 deletes
  Unnamed register is default target for yanks, deletes. default source for puts
  Named registers
    "% - useful for sourcing vimrc 
    "0 last yank
  macros are related to registers
  macro is just a recording of keystrokes into a register
  tips for reusability
    move the cursor by searching
    pay attention to the start and end points
  A-Z are global
  0-9 where you exited vim
Text states (think branches of undo tree): 
  g-, g+, 
  :earlier, :later
Bind lots of leaders
  mine my dotfiles for ideas:
:set number so you can jump to lines (holdng j or k is a vim smell)
gi (go to last insert)
Change/delete inside ( { " '
c-o for undoing jumps


setup: install exuberant ctags, 
       run ctags -R in rails dir (after vendoring rails so it can pick up tags)
C-] on identifiers, or :tag <identifier>
:ts[elect] <identifier> for tags with mult. matches


:help rails to learn all commands
Rcontroller  --> jump to controller
RVcontroller --> "    "  "          in vertical split
RScontroller --> "    "  "          in horizontal split
Rmigration   --> jump to latest migration
Rinvert      --> writes the self.down of a migration for you!
Rake in a fileruns tests or migrations
Rextract will extract a partial highlighted in visual mode


installation instructions on my blog:


cs = change surroundings
ex: cs'"  <-- change surrounding single quotes to double-quotes
ds = delete surroundings
ysw' <-- surround this w(ord) with single quotes
Bonus material:


cla (multi-choice AND calls out to vim)
easy to write your own
Something went wrong with that request. Please try again.