Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

As I understand it, vi's author, Bill Joy, used a terminal that placed arrow symbols on hjkl because it did not have dedicated arrow keys.

Wikipedia backs up this story: http://en.wikipedia.org/wiki/HJKL_keys#HJKL_keys



sort by: page size:

There were no "traditional arrow keys" on the terminal that vi was developed on, but arrows were printed on the hjkl keys; see https://en.wikipedia.org/wiki/Arrow_keys#HJKL_keys.

Vim inherited the keyboard mapping from vi. vi was designed on a QWERTY (American) keyboard, but the particular terminal that the author used had arrows printed on the hjkl keycaps.

More information at: http://en.wikipedia.org/wiki/Vi


the other answer is also correct but you are correct as well! The machine vim was developed on didn't have arrow keys but used hjkl for arrows: http://www.catonmat.net/blog/why-vim-uses-hjkl-as-arrow-keys...

Just to state some support for this: I have used vim for over a decade and I haven't used hjkl on a good day once. Arrow keys are fine.

Occasionally I use hjkl if the terminal is set up wrongly or it's a broken vi implementation but that's it.


vi, which vim is based on, was programmed on the ADM-3A terminal, where the arrow keys are on the H, J, K, and L keys.

http://www.catonmat.net/images/why-vim-uses-hjkl/lsi-adm-3a....

http://www.catonmat.net/images/why-vim-uses-hjkl/adm-3a-hjkl...


My dad said a big advantage of the hjkl navigation keys in vi were that they were single character. The arrow keys were multi character, so if the escape character got dropped, you would end up sending control codes as plain text

https://catonmat.net/why-vim-uses-hjkl-as-arrow-keys

Apparently the use of hjkl has to do with the fact that on some keyboards, those WERE the arrow keys!


You don't have to. The arrows work just fine. You can use 'hjkl' (or whatever pleases you), and many people choose to, for the main reason that having navigation keys in the home row is really nice.

Having navigation on 'hjkl' for me was never about a lack of arrow keys, and has always been about convenience. The reason it's specific to Vi/m is that you need a modal editor to be able to pull it off.


This may just be an urban myth but afaik Vim uses hjkl because the terminal[1] that it was originally used to write Vi had a keyboard where the arrows were on those same keys.

Also, the escape key was in the place of the modern day tab key making switching modes much easier.

[1]: http://en.wikipedia.org/wiki/ADM-3A


AFAICT it's only common in for developer-oriented tools that want to be familiar to vi users.

The average writer has probably never seen hjkl navigation before, and it is much harder to get used to than a slightly off-center "i" key.


>I really don't understand why people get hung up on this. Vim supports arrow keys. hjkl are convenient alternatives [...]

Maybe because tutorials like vimtutor and this thread's website immediately blast hjkl finger exercises at the brand new user with no context whatsoever. The student is now wondering why they are pressing a seemingly arbitrary and random alphabet key just to move a cursor around.

E.g. vimtutor 1st screen:

  Now, make sure that your Caps-Lock key is NOT depressed and press 
  the   j   key enough times to move the cursor so that lesson 1.1
  completely fills the screen.
E.g. this website's 1st instructions:

  You can use the h and l keys to move the cursor.
For learners that need a little bit of scaffolding in the brain to make sense of what keys to press, a little bit of history about the origins of "hjkl" helps.

Also, in my case, I learned classic vi (not vim) on DEC UNIX and the arrow keys did not work. Instead, the arrow keys inserted funny control characters depending the terminal emulation. So people used to be forced into using hjkl.



Bill Joy used an ADM 3A[1] terminal, and looking at the keyboard layout explains vi's key mappings almost entirely.

There are arrow keys printed on HJKL (accessed via control), escape is left of Q, control is left of A, and colon has a dedicated key rather than being shift+semicolon.

Another tidbit is that the home key is also used for tilde, which explains its association with the home directory.

1: https://en.wikipedia.org/wiki/ADM-3A#/media/File:KB_Terminal...


Agreed. Hjkl only makes sense when using a keyboard layout where these 4 keys are located in a row. This fact made most vim tutorials useless for me, as I'm using the neo2 keyboard layout, where arrow keys are located in the middle of the keyboard and hjkl are not in a row. Using vim works well for me, and I can use hjkl for other keybindings.

As a former Vi user, I can kinda grok not liking arrow keys.

(_My_ arrow keys are the ones on the numeric keypad -- I almost never use Numlock. This is a hold-over from my first computer: An IBM PCjr that had arrow keys in a diamond layout instead of that hateful inverted-T layout that cramps one's thumb.)


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)


Vim supports arrow keys as well as hjkl (although the original vi only uses hjkl; it was designed for use with a keyboard that does not have separate arrows).

I knew the things listed here, although not all of the details they mention. For the months, I would have used 1 for January (due to the convention in most things), but otherwise implement the code in a similar way to what they have there, effectively using 3 less than the string address as the base offset; in assembly language (and in an optimizing C compiler) this would be equally efficient to the code that they have.

(Also, the arrows in Dance Dance Revolution are also in this order; I don't know if that is just a coincidence though. It does mean that an implementation using a computer keyboard could allow keys HJKL to be used, and it is easily understandable.)


I liked this piece overall, but there's one part that annoyed me.

Something else that had long-lasting influence over software we still use today was the ADM-3A terminal. If you ever wondered why vi uses 'hjkl' as left,down,up,right - this is why.

You won't find anyone who believes more strongly than I do in the importance of understanding our history. But understanding history is different than making a fetish of it, and this explanation tiptoes pretty close to the latter. OK, vi uses hjkl because the ADM-3A terminal didn't have arrow keys. But every keyboard for decades now has had arrow keys. Given that, what's the value in pretending they do not?

This explanation basically boils down to "we do it that way because we've always done it that way," which is poor argumentation.

It's also a good illustration of the distinction between 'easy' and 'efficient' - the modern cursor key layout, with the 'up' in front of the 'down', is obvious, intuitive, and easy to master. No argument. But it's not the most efficient layout - it's not possible to keep all four fingers on the four navigation keys - you have to settle for three fingers and move them around. And if you're typing and suddenly need to move, you have to move completely away from where you're typing and switch to the cursors.

hjkl answers both issues - the four keys in a line make it possible to keep one finger on each and so move about as quickly as possible, without ever having to move from the text-entry part of the keyboard to any other. It's not as easy, not as obvious, but it's quicker and more efficient when you're used to it. Even on my modern keyboard, I go for hjkl far more than I reach for cursors.

Well sure you do, because you have trained yourself to do that. But how many people can say that? And what's the value in leaving everybody else out when you design your tools?

Anytime you talk about how UNIX-like systems have evolved, there's a danger of falling into the trap of hailing historical cruft as "misunderstood features." But at the end of the day, it's still just historical cruft. It's there, it won't kill anyone if it stays there, but it's not something awesome either. It's just an evolutionary dead-end; the male nipple of software design.


Doing this is definitely worth it -- in fact, it's how vi was meant to be used [0].

Also, it's worth noting that on OSX you can do this without any additional software. Just remap it in the keyboard settings.

[0] http://www.catonmat.net/blog/why-vim-uses-hjkl-as-arrow-keys...

next

Legal | privacy