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

Learn to speak vim – verbs, nouns, and modifiers!

Posted 16 December 2011 @ 12pm in vim

Using vim is like talking to your editor in ‘verb modifier object’ sentences, turned into acronyms

  • learn some verbs: v (visual), c (change), d (delete), y (yank/copy). these are the most important. there are others
  • learn some modifiers: i (inside), a (around), t (till..finds a character), f (find..like till except including the char), / (search..find a string/regex)
  • learn some text objects: w (word), s (sentence) p (paragraph) b (block/parentheses), t (tag, works for html/xml) there are others

To move efficiently in vim, don’t try to do anything by pressing keys many times, instead speak to the editor in sentences

  • delete the current word: diw (delete inside word)
  • change current sentence: cis (change inside sentence)
  • change a string inside quotes: ci” (change inside quote)
  • change until next occurrence of ‘foo’: c/foo (change search foo)
  • change everything from here to the letter X: ctX
  • visually select this paragraph: vap (visual around paragraph)

If you understand the verbs and objects you’re dealing with, you will soon realize that adding a new plugin and learning a new verb or noun exponentially increases your productivity, as you can now apply it in all the sentences you already know. It’s just like learning a language.

Let’s add some new text object plugins!

  • install surround.vim: vim-surround- you get a new noun, the ‘surround’ (s or S)
    • visually select a word and surround it with quotes: viwS”
    • change surround from single quote to double quote: cs’”
  • install vim-textobj-rubyblock – you get a new noun, the ‘ruby block’ (r)
    • delete current ruby block: dir (delete inside ruby block)
    • visually select a ruby function: var (visual around ruby block)
    • visually select the innards of a function: vir (visual inside ruby block)
  • install tComment – new verb: gc (go comment)
    • comment the current ruby method: gcar (go comment around ruby)

Now go out and learn a new verb or noun every day!

Love this article? Here are some more you might like :)

Want an exceptionally curated collection of vim plugins and shortcuts?

Check out an early beta preview of my fully modularized vim/dotfile setup called YADR (Yet Another Dotfile Repo) which includes text object plugins for ruby blocks(r), indents(i), dates(da/df), function arguments(a), and ruby symbols(:)