Hacker News new | past | comments | ask | show | jobs | submit login
Learn to speak vim - verbs, nouns, and modifiers (yanpritzker.com)
208 points by skwp on Dec 16, 2011 | hide | past | web | favorite | 33 comments

I am ashamed to say that this made me giggle like a girl.

I guess I'm the kind of guy that understands and learns in this way better than seeing visual cheatsheets or long-winded reference pages. Up until now I've just been remembering particular sets of vim commands but this will really make me a lot more productive I'm sure. :)

I am not fully vim fluent, but I found this presenting angle confusing at best.

Perhaps it helps to remember more easily if one already knows and uses all the basic commands. Personaly I don't use vim all the time and have trouble keeping a good mental model of the different commands behaviour depending on the state of the document.

Telling me "hey, y is not some command acting against a state, it is a verb, just use it with nouns like you use verbs!" is just counterproductive.

completely off-topic, but I had a hard time to visualize how it is to "giggle like a girl". Even googling and youtubing left me puzzling at the exact way to giggle you wanted to express. It is kind of fun and curious.

PS: responded to this post for the OT bit. not that it was a direct reply.

I agree. This article helps me understand why Vim has been so fun for me to use.

I guess I have been doing this naturally for years and didn’t realize it till just now. It’s almost a telepathic connection; just think the word and the computer responds.


If this gets people into vim and helps them understand some of its craziness, that's awesome. However, like previous commenters have pointed out, most of these examples are actually wrong (not by a mile, but it pays to be precise in vim). Also, even though I love browsing through dotfiles and plugins on code repository sites, I tend to think that beginners to vim should learn slowly, gradually, and build up their knowledge over time, like anything else. Diving into plugins and custom mappings right away is going to be a lot more painful and less productive. And that's the antithesis of vim.

sorry, made some mistakes late at night. but "most" examples wrong? I think I only screwed up on the $ examples. if you see anything else wrong can you please point it out, so that I can fix em and not mislead people, thanks!

This is similar to the post Your problem with Vim is that you don't grok vi at http://stackoverflow.com/questions/1218390/what-is-your-most... (also on HN somewhere).

I'd been familiar with the concept of verbs and nouns in vim but this really simplifies it all. I wish there was a more comprehensive list of everything in a readable format. Man pages just don't do it for me :(

I'll try to expand the post as I internalize the learnings myself. I'm no vim expert, I just find that explaining it to others helps me solidify my own learning

Have you see https://github.com/LevelbossMike/vim_shortcut_wallpaper/raw/...? It's pretty much instinctive for me now, but if I was starting out, this would have been invaluable.

I have that wallpaper with a green background on my wall. I think the author posted it here a few months ago.

This has some mistakes. yt$ is not equivalent to yy - yt$ yanks from the cursor to the end, yy is equivalent to 0yt$

Actually it's even bigger than that. yt$ does not include the newline, yy does. So p after a yt$ will not change lines, it will insert the content directly on this one after your cursor, while p after a yy will reproduce the entire line as a new line below the current one.

Are you sure that yt$ will do anything if there is not a dollar-sign character on the line? Neither that or ct$ seem to do what the post advertises.

y$ will yank till the end of line (characterwise). Y is actually the same as yy, unless you n(no)remap Y to be the same as y$, which most people do. This makes make more sense, because C is the same as c$ (change till end of line). ':h change.txt' explains all of this and more a lot better than I could.

thanks guys, I wrote the post at 3am and that was a bad time to be writing about vim as it turns out :) I've removed the bad examples for now and will go back to the post and add more as I think of them. The general idea was to explain that vim is not voodoo, but is very mnemonic and conversational.

The commands the OP was looking for was c$ and y$. They are equivalent to say cw, where the object is "end of line" instead of "current word"

There's another mistake in that command (also present in the article): with that "t" in there, `yt$` will yank up to, but not including, a '$' character on the current line. Unless there is no '$', which is an error and no yanking. Yank from cursor, not including newline, is `y$` without a "t".

and capital Y is equivalent to y$. A capital letter for a verb is "do this verb from current location until end of line"

Y is an exception to that rule, it's a synonym for yy (like S for cc), but easily changed to match D and C.

Ah wow, you are correct. Any good reason that is the default behavior for Y?

These kinds of blog posts always forget the 's/S' (substitute) operator. I find it super-useful.

it feels like the substitute operator doesn't follow the sentence conventions. you can't saw (substitute around word) or anything like that. it feels like a standalone bit of functionality. I was trying to express reusable bits in my post, things you can build on and expand. am I wrong?

Useful - I found that mapping keys to actual verbs in my head as I'm using vim really helps the memorization process.

This doesn't exactly work for everything though... I'm still having trouble remembering movement keys (still using the arrow keys instead of hjkl...).

If you just force yourself to stop using the arrow keys you'll be surprised at how quick it just becomes muscle memory. As far as remembering them until then, I suppose they're kind of like the arrow keys in that left and right are on the outside with up and down in the middle.

For what it's worth vim has been my main editor now for 2+ years and I still don't use hjkl. I know I should, but I can't seem to get over the hump that I can easily find arrow keys by feel, but not hjkl.

As for remembering them, left and right are on the outside, and 'j' kind of looks like a down arrow (that's how I distinguish j from k)

I've been using Vim for something like a decade, and I only recently started toying with hjkl. At first, I ignored it because I was already pretty good with the arrow keys and hjkl are annoyingly not quite the home keys; then I ignored it because I switched to Dvorak and hjkl are scattered across the keyboard.

Strangely, it was Google+ that got me interested in hjkl, or at least J and K for moving up and down. In the Dvorak layout, J and K are where C and V are in QWERTY, so they're still pretty convenient to reach for.

You can just remap the arrow keys to do nothing in vim, and within a few days or so you'll be comfortable with hjkl. It's not a big deal - just do this if you want it.

You should start using j and k in other places like gmail to start getting used to it. I know it takes some work, but I think it is totally worth the effort.

I still use them as well but not for moving though my code. /?fFtT and things like ]] beat both the arrows END hjkl hands down, I think.

Is there any way to use a / search as the target object with these sorts of commands? I'd like for instance to be able to type ct/foo<cr> and have it delete to the next instance of foo and put me in insert mode. Or something along those lines.

/foo<cr>c`` may be what you're looking for (see :help ``)

Simply c/foo should work, if I understand you correctly.

Oh thanks, for some reason I thought I tried that before and it didn't work. Awesome.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact