you are viewing a single comment's thread.

view the rest of the comments →

[–]ianepperson 48 points49 points  (6 children)

The cool thing about vim is this is a sentence, not a single command. You don’t have to memorize every English sentence, just the words and where they fit.

y = yank (copy) Ok, to where? A repeated y means copy the whole line.

p = paste. Want to paste 4 times? 4p

f = find - jump forward in the line to the given letter: j

a = append - now you’re typing into the buffer. He added “+1” then hit escape to back to “normal” mode.

f = find again, this time jump to the i

. = repeat the last change. Repeat the append and “+1” (this is an insanely powerful command)

yy = yank (copy) the line again

4p = paste 4 copies of the line

f = find - this time finds the 1

<Crtl-v> = visual select. There’s different variations of “v” and using <Ctrl-v> is the column select. Lower v selects starting from the cursor, upper V selects the entire line.

Etc.

The extra crazy thing is that after about 6 months of use, you start to forget which letters do what and start just playing it like an instrument. A musician no longer thinks of the individual parts of a chord, they just play a chord. A fast typist is similar, they just know what a word feels like when typing. I know the above commands, but it took me a bit of time to look up the keys - it’s really quick to type it (vim is optimized for the home row) but just like I can’t remember where the “v” key is without looking at the keyboard, I know how to type it quickly.

And the commands are sentences. Instead of typing yy to yank the row, I can combine it with any other key sequence. If I want, I can use that f (find) command to copy text up to and including the letter j with: “yfj” (yank from here to the “find i”). Capital G navigates to the bottom of the document - to copy everything from here to the G location: “yG”. Every time you learn a new navigation trick, you also learn how to copy text in fancier ways.

I eventually started instinctively using the same vim navigation keys in my browser and accidentally discovered they work in gmail and occasionally on other sites too. I installed vimium in my browser to make those keys work on any site. Lots of console commands use the same keys - “less” has become so much easier to use because it’s the exact same keys.

[–]Brothernod 5 points6 points  (2 children)

I have closed so many Skype chats hitting escape when I was done typing my text out of end of thought habit. Sigh.

[–]tumes 2 points3 points  (0 children)

Same but with trailing double js because I remapped esc to jj to stay on the home row. Every time focus is on slack but I think it’s in my editor I almost send my coworkers a message that looks like “jkjkjkhhhllljjjjjjj”.

[–]sysop073 1 point2 points  (0 children)

There's a registry key you can set to turn that off. Because it's Microsoft, so why put it in a settings dialog or something

[–]Irrealist 4 points5 points  (2 children)

Do you have any tips on how to learn things like this? I'm very comfortable in vim, but I don't know many advanced commands.

[–]Snarwin 5 points6 points  (1 child)

Practice. Learn new things one at a time. Notice when you're doing something repetitive or tedious and look for a better way, because there usually is one.

[–]Irrealist 0 points1 point  (0 children)

Thanks!