Hacker News new | ask | show | jobs
by levthedev 3177 days ago
Many people rebind caps lock (or another easy to reach key) with escape. This way they can quickly change modes.

Also, most beginners use insert mode too much. If you find yourself going into insert mode just to change a letter or word, try learning shortcuts instead (r for replace, ciw for replace word, diw for delete word, and other neat command combinations).

2 comments

That was my initial thought. I do use r to replace one letter, and ciw or ci" to change whole things. But still, after all this time, I find it simpler to just go in insert mode and do 3-4 things, than think of combinations or commands for every single thing.

Maybe I'm too lazy to memorize them, I don't know.

But using hjkl is still too weird for me, even after using vim for more than 6 months. :)

I don't usually have this problem. On a dev machine I install a more featurefull vim. I think there's a difference in how "tiny vim" most distros ship with and other vims handle navigation. Seems like tiny vim is closer to vi in enforcing hjkl in insert. I'm sure some reading this knows more than I do about this.
> But using hjkl is still too weird for me

It's very natural to use j and k. When you touch type, "j" is your right index home base (I assume you know it but that's why there's a physical marker on "j" and "f").

I mean from a layout perspective. hjkl is in one line, whereas the arrows are not in one line, with "up" one line above "down". That's a muscle memory I cannot fight yet.
One of my favorites: xp to exchange characters.

x cuts the character under the cursor and p pastes it after the cursor. Net effect is exchanging the character on the cursor with the one to the right of the cursor.

You can do the equivalent lines with:

    ddp
dd deletes a line and p pastes the deleted line below the current line. Since your cursor ends up in the line after the line you just deleted, this ends up effectively exchanging the lines.