6

Currently unix text editor vi has the following keys for navigation.

h   move left   
j   move down    
k   move up     
l   move right

On keyboard they aligned: Left, Down, Up, Right

But while typing normally we move from top-left to bottom-right, so Left, Up, Down, Rightis more intuitive.

So why its developer selected that order?

Indeed I used AutoHotKey app to simulate this shortcuts in windows-wide. And I vacillate between following vim style or using mine!?

7
  • 3
    If you have your index finger on j and middle finger on k, it feels more natural to have the shorter (therefore slightly lower) and also more dominant index finger scrolling down and the higher middle finger to move up. ? Nov 26, 2012 at 10:02
  • 1
    By the way, Dance Dance Revolution uses Vi-direction arrows
    – Izkata
    Nov 26, 2012 at 13:25
  • @RogerAttrill Thanks, Really it make that a little more natural :) Nov 26, 2012 at 13:39
  • The vi cursor key order also influenced that of later home computer keyboards. The Sinclair ZX80, ZX81 and ZX Spectrum in the 1980s all mapped left, down, up and right to the 5, 6, 7 and 8 keys, for example.
    – calum_b
    Nov 26, 2012 at 14:23
  • 1
    I have the same confusion with the up and down keys. My mnemonic: "Fuck up" - since "up" is your middle finger. Nov 27, 2012 at 20:38

5 Answers 5

21

The answer is more trivial than you probably think - it's because h, j, k, l were respectively left, down, up, right arrows on the ADM-3A terminal which Bill Joy used when creating the original Vi [1].

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

5
  • 7
    @Thanks, So now question is about "unintuitive ADM3A keyboard layout" ! ;) Nov 26, 2012 at 13:46
  • 3
    Related fact: Ctrl+H sends the ASCII code for backspace, so having left arrow on H kinda makes sense. Likewise, Ctrl+J sends newline, so down arrow makes sense. Ctrl+K sends vertical tab and Ctrl+L sends form feed, which don't map quite so nicely to 'up' and 'right', but are still in the ballpark.
    – calum_b
    Nov 26, 2012 at 14:36
  • On the ADM-3A, those meta-behaviors required the Ctrl key, so Ctrl+H and Ctrl+J were left and down (and pre-dated that terminal). It's only the behaviors of +K and +L that were "created"
    – Plutor
    Nov 26, 2012 at 16:57
  • 1
    That's basically it. vi copied ADM-3A. ADM-3A had that format because of the way control used to work. What the control key used to do was drop bits 6 & 7 of the ASCII character. That caused HJKL to map to ASCII control codes 08 (backspace/left), 12 (linefeed/down), 13 (vertical tab/up) & 14 (form feed/right). Since those four keys were on the home row you could sit there holding control and move around very quickly.
    – adrianh
    Nov 26, 2012 at 17:51
  • @scottishwildcat: Since teletypes didn't support a "reverse paper feed" function, ASCII didn't define a code for that; some video display terminals, however, used control-K for such a purpose. I don't know if any used control-L for cursor right, though; that was more often clear-screen (similar to ejecting a page). The Apple ][ mapped cursor-right to control-U if I recall.
    – supercat
    Jul 29, 2014 at 22:03
3

Even ignoring the historical background, I prefer j to be the down arrow because it's under my index finger and the key has a mark that can be easily felt. As it is the direction key I use most, I consider it a good fit.

3
  • Personally the key I would use the most is Left, so it would make more sense for me for this to be the function for J. But all that proves is that everyone has their own subjective preference, so unless VI tested with a huge user sample and came to this reasoning (unlikely) then the other possibility as to why this was chosen is neatly summarised by @Mariusz.
    – JonW
    Nov 26, 2012 at 15:12
  • In think up and down keys in average are used equally. You have to go up before going down in a text editor Nov 27, 2012 at 16:22
  • 2
    If you editing, yes, but when you read text down is the way to go. Especially if you use Vim for non-programming text, or simply read logs, the J key is usually more used than K.
    – BoppreH
    Nov 27, 2012 at 18:04
2

The way I see it, the advantage is speed through efficiency of motion. People who use Vi or Vim these days tend to be expert users. Design for expert users is totally different than your average consumer. Expert users will generally take the time to learn and remember complex shortcuts if they have enough of a speed payoff.

I personally use Vim for all my development, because it's that much faster. Moving your hand back and forth between the mouse and keyboard takes a lot more time than you think it does. The same applies to moving your hand to different parts of the keyboard. By putting the "arrow" keys right under your fingers, users don't need to move to access them.

It's almost always faster to keep information in the mind than on the screen. The same works for the keyboard: it's faster to just remember that j is down than to move your hand to a separate part of the keyboard that provides a visual key mapping.

Vim is terribly complex, but it's specifically designed to minimize keystrokes. The layout of the specific keys is an arbitrary mapping carried along from the early days, but learning that mapping is something you just do once and move on. It's not intuitive at all, but that's not the point of this design. The goal is speed.

0

More intuitive keys would be j(<), i(^), k(>), m(v) (assuming your keyboard has the same layout as mine - Ergonomic qwerty), however, as Mariusz pointed out, the consideration behind vi's key assignments was no based on consideration which keys would be the intuitive.

7
  • 2
    Any literature to back this up? Nov 26, 2012 at 13:24
  • 2
    @ Your order is even more intuitive, but I thing its creator wanted to use home row keys for this task. Nov 26, 2012 at 13:24
  • @VoronoiPotato literature to back up that the up should be on top and the down below!? Do you need literature to back up the arrow keys placement on your keyboard? Nov 26, 2012 at 13:59
  • @Reza there are not many things in old *nix systems that are user-experience oriented. That was not a major consideration. Nov 26, 2012 at 14:00
  • 1
    I'm just saying why that particular configuration. If we were not restricting ourselves to homerow why not the more ubiquitous WASD. Nov 26, 2012 at 14:45
0

Despite the various stories regarding the origins of the pattern, I think there really is only one reason why the keys are in that order today.

It's the same reason that cars have many of their interface conventions: there was an old system whose engineering limitations demanded an awkward configuration.

Everyone since then has been trained on the old system, and making a better interface with today's technologies would alienate users of older systems, and potentially lead to accidents.


Except, with Vim, we had an alternative: let people use the arrow keys. The arrow keys have the advantage of being morphologically similar (relatively arranged) to the directions they represent.

As has been discussed, the most-significant reason to maintain use of the hjkl mapping is to break the bad habit of moving via 'arrow-movements,' and instead move to exact locations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.