Yan Pritzker photographer, entrepreneur, software engineer, musician, skier

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

TwitterCounter for @skwp

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

hello, i'm yan

I am a photographer, entrepreneur, software engineer, 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 chief technical something or other at Reverb.com - The Marketplace for Musicians. We're hiring web designers!

Recent Tweets

Selected Reading

Archives

Contact

Reach me at yan at pritzker.ws

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

Posted 16 December 2011 @ 12pm in vim



Submit to HN

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(:)

27 Comments

Posted by
ales
16 December 2011 @ 5pm

I have been using vim for a couple of years now, but never thought about it like this. Thanks for the interesting insight!


Posted by
Kris
16 December 2011 @ 6pm

Holy… wow, this is quite the improvement I just got. I learn much better when I understand the idea behind something, and while I knew the verb-modifier-object structure, the ‘in’ and ‘around’, as well as combining them with quotes, parenthesis, sentences – those will improve my workflow quite a bit. Cheers!


Posted by
Matt
16 December 2011 @ 8pm

ct$ does not “change till end”, it “changes till dollar sign” (as in, an actual dollar sign in your text). If ct$ did “change till end”, it would not be equivalent to cc, which is “change the entire current line”, it would be equivalent to C, which is “change from current location to end of current line”


Posted by
Victor
16 December 2011 @ 9pm

@Matt

There are exceptions too :) But I like the whole idea. It’s good to see Vim commands put that way.


Posted by
Yan
16 December 2011 @ 10pm

oops thanks Matt! should have double checked myself :)
@Kris thanks. I made a monumental leap in vim once I got the verb/noun understanding. It should be stated much more clearly in the tutorial!


Posted by
Pet
17 December 2011 @ 4am

Realy nice idea how to learn/teach vim. Big thanks.


Posted by
googya
18 December 2011 @ 6am

nice article! after It’s so important to understand the verb and object! thank you!


Posted by
Elliot Smith
19 December 2011 @ 1am

Really helpful post. I sort of know in the back of my mind that the commands all stood for something useful I just hadn’t taken the time to look into it. It’s always nice when seemingly complex things turn out to be simple like this.

Thanks, Elliot


[...] http://yanpritzker.com/2011/12/16/learn-to-speak-vim-verbs-nouns-and-modifiers/ A great clever way to use and learn Vim: speak to him! [...]


Posted by
Eric
19 December 2011 @ 9pm

Thanks for pointing out some extensions I haven’t heard of. Here’s my contribution:

Install argtextobj: you get a new object, the argument or ‘a’

http://www.vim.org/scripts/script.php?script_id=2699


Posted by
Yan
20 December 2011 @ 3am

@Eric awesome thanks for pointing that one out. I am adding it to my setup, which I’m tweaking for a 1.0 release slated sometime in January probably. I already have textobj plugins for ruby and indent blocks in there. If you aren’t already following, check out https://github.com/skwp/dotfiles – I would love feedback


Posted by
‘Speaking’ vim « 0ddn1x: tricks with *nix
20 December 2011 @ 11am


Posted by
Infovore » Links for December 21st
21 December 2011 @ 12pm

[...] Learn to speak vim – verbs, nouns, and modifiers! – Yan Pritzker "Using vim is like talking to your editor in ‘verb modifier object’ sentences, turned into acronyms." Which is a good way of thinking of it. (tags: vim editor text ) [...]


Posted by
Speak Vim | fozbaca’s WordPress
23 December 2011 @ 10am

[...] Yan Pritzker: “To move efficiently in vim, don’t try to do anything by pressing keys many times, instead speak to the editor in sentences.” [...]


Posted by
tony
29 December 2011 @ 8pm

But “i” is “insert” and “a” is “append” and “r” is “replace”.
To move efficiently, is just a matter of knowing built-in stuff like 2{ (up 2 paragraphs), f5t (forward to the 5th “t”), 5j (down 5 lines), etc.


Posted by
landmark mumbai
21 March 2012 @ 6am

I have been using vim for many years now, but never thought about it like this.Really thanks for the interesting insight.


Posted by
Why Vim? | Terminally Incoherent
21 March 2012 @ 9am

[...] Pritzker apptly explained it like this: vim commands are like a language you can [...]


[...] “Smash Into Vim” video (which I highly recommend) likened it to “text surgery    http://yanpritzker.com/2011/12/16/learn-to-speak-vim-verbs-nouns-and-modifiers/  [...]


[...] I’ve just come across this excellent article on learning to speak vim, to get a more in depth [...]


Posted by
Fabio
5 June 2012 @ 7am

I want just to point out that d$ is enough to delete until the end of the line. command and location. “delete”. Where? “end of the line”.
“0″ is beginning of the line. So d0 delete from cursor to the beginning of the line.
c0 changes text to the beginning of the line (read: delete it AND enters insert mode) and the like.

Thanks for the article though, I didn’t knew about the “i” modifier. I used “a” (daw = delete a word). I will check to see if they behave the same or if there’s any difference.

Thanks!


Posted by
Resources For Learning Vim ⊆ David Xia
21 June 2012 @ 9am

[...] Learn to Speak Vim – Verbs, Nouns, and Modifiers [...]


Posted by
Quora
31 July 2012 @ 6pm

What are some guidelines for remembering arguments in vim?…

By “arguments in vim” I’m assuming you’re asking about remembering various commands in vim. To check on vim’s command line arguments you can just type “man vim.” Stringing together keystrokes in vim is like a speaking a language. vim has verbs a…


Posted by
students accommodation manchester
13 February 2013 @ 11pm

KiyaKhoobsuratAlfaz HAIN this is like a comment about Mark


Posted by
Do's and Don'ts for Learning VIM - Fränk Klein
14 February 2013 @ 3pm

[...] Learn to speak vim – verbs, nouns, and modifiers! by Yan Pritzker [...]


Posted by
Haralan Dobrev
17 February 2013 @ 4pm

The link for navigating files in vertical splits – http://yanpritzker.com/2012/03/12/vim-navigating-files-in-vertical-splits/

uses hhttp protocol. Chrome on Linux tells me it will launch an external program for it :D :D


[...] important for me is that vim provides a language of commands, not a list of hotkeys. I spend many hours every day writing code. With other editors I’ve [...]


Posted by
six pack abs shortcuts pdf
17 May 2013 @ 12pm

Wow a few of the idiotic remarks ive seen on right here.
First all pros use steriods

Also visit my blog: six pack abs shortcuts pdf


Leave a Comment

To post code, use <code></code> tag around your code