Live data from Hacker News

Here is why vim uses the hjkl keys as arrow keys

catonmat.net

71–80 of 100 posts

Re: Here is why vim uses the hjkl keys as arrow keys

#71
post #36

Earlier quoted context omitted.

I prefer caps lock to Control. ^C does the same thing as escape in Vi[m]. While it is chording, the combo is pretty easy to hit. This is a bit of a compromise, but all the other programs that are not vim will benefit from it.

Another excellent trick I read somewhere is to map 'jj' or 'jk' to esc when in insert mode (so 'inoremap jj '). As a digraph they never occur in a natural language, so you'll never type it accidentally. And you can hit it on the home row easy-peasy. Although personally I type in Colemak, I still use this, just with 'yy' instead. To be honest, it's a barely noticeable slow-down but it's much less stressful for my hand…

> As a digraph they never occur in a natural language

I wonder how Dijkstra would react to that statement.

Re: Here is why vim uses the hjkl keys as arrow keys

#72

This feature of vi/vim along with not being able to save and quit as quickly as I can in emacs (ctrl-s ctrl-x, baby, none of that :q! shite) is the reason I use emacs. I totally respect those that use vim, but I'm not a freaking machine.

I can hit ZZ faster than ctrl-x ctrl-s ;)

Re: Here is why vim uses the hjkl keys as arrow keys

#73

Most of the answers I've seen as to why hjkl have fallen into the "so your fingers stay on the home row / it's actually quite fast once you get used to it" realm. But those answers were never completely satisfactory to me. Once you get used to it, it's fine. But I feel like it would have been fine as adsw, or jkl; (so that your hand really is on the home keys) or some other 4 key combination near the home row, too. T…

The reason it stuck is because it was grandfathered in, not because it is the best way to do it. Same as most things, like qwerty etc. People just naturally do things the way they always did things.

Re: Here is why vim uses the hjkl keys as arrow keys

#74

Most of the answers I've seen as to why hjkl have fallen into the "so your fingers stay on the home row / it's actually quite fast once you get used to it" realm. But those answers were never completely satisfactory to me. Once you get used to it, it's fine. But I feel like it would have been fine as adsw, or jkl; (so that your hand really is on the home keys) or some other 4 key combination near the home row, too. T…

I have another good suggestion: learn pressing the left control with the side of your palm. It's usually a very minimal movement, and I find it a lot easier (and less straining) than moving the pinky to press control. The only drawback is that it doesn't really work on a laptop keyboard.

I picked that up a few years back playing World of Warcraft and some other games, to avoid having to move my left hand away from WASD as much as possible, but it has served me very well in a lot of other applications since then.

Edit: Well, that was supposed to be an answer to cheatercheater below this comment. Woops.

Re: Here is why vim uses the hjkl keys as arrow keys

#75
post #49

Earlier quoted context omitted.

Never knew that Ctrl-C does the same thing as escape. Thanks for the info!

They're not exactly the same thing, actually, ctrl-c doesn't allow you to expand abbreviations and doesn't trigger the InsertLeave autocommand, but to be honest, I don't think it's that big of a deal. I go between ctrl-c and ctrl-] without thinking.

If you use q: or q/ to edit the command or search history, ctrl-c will close the edit buffer rather than swap out of insert mode.

Re: Here is why vim uses the hjkl keys as arrow keys

#77
post #57
post #37

If anyone is apprehensive about vim's hjkl keys, and you like the arrow keys better, you can use ijkl instead and get all the benefits of the muscle memory you have built up for arrow keys, while still keeping your hands on the home row. Use this mapping: " remap h to i and use ijkl for inverse T cursor movement map k g map i g map j noremap h i Then the 'i' key will be replaced by 'h'. So press 'h' to insert, or for…

I'd recommend specifying a mode on those. That i map disables half the text-objects in visual and operator modes.

I still use those text-objects, just with h instead of i. This is required because otherwise, you'll have issues when trying to move in visual and other modes.

Re: Here is why vim uses the hjkl keys as arrow keys

#78

Doesn't this go way back though? The reason that keyboard had those arrows keys on it was because those keys correspond to CTRL-H, J, K, L and the CTRL key back then worked by killing bit 6 (and bit 5) of the characters being typed. The effect was that H which is ASCII 0x48 would become 0x08 which is backspace. If you look at an ASCII table (e.g. http://www.asciitable.com/ ) you will notice how the uppercase ASCII le…

And that's the source of the old joke where 'overwrite' something unfortunate with ^H^H^H^H^H.

Re: Here is why vim uses the hjkl keys as arrow keys

#79
post #71

Earlier quoted context omitted.

Another excellent trick I read somewhere is to map 'jj' or 'jk' to esc when in insert mode (so 'inoremap jj '). As a digraph they never occur in a natural language, so you'll never type it accidentally. And you can hit it on the home row easy-peasy. Although personally I type in Colemak, I still use this, just with 'yy' instead. To be honest, it's a barely noticeable slow-down but it's much less stressful for my hand…

> As a digraph they never occur in a natural language I wonder how Dijkstra would react to that statement.

Or all those people whose handle is JJ?

Re: Here is why vim uses the hjkl keys as arrow keys

#80

Another reason to use HJKL is that over a 1200bauds line, it is faster to send a single byte than the 3 bytes generated by the arrow keys (^[[D^[[A^[[B^[[C)

The ADM3A was a "dumb" terminal, constructed using a board full of 7400-series TTL ICs with no microcontroller. Probably to simplify the design, it wasn't capable of sending any multi-character escape sequences. (The ANSI escape sequences hadn't been standardized at that point yet either.)
Post reply on HN