Results 1 to 10 of 10

Thread: Why vim uses h, j, k and l to move the cursor?

  1. #1

    Why vim uses h, j, k and l to move the cursor?

    Anyone knows the mnemonics to remember where each key moves the cursor to?

    I can't find the documentation telling why those keys were chosen, I remember it
    was something like:

    Code:
              ???
               k
               | North
           /-------\
           |       |
    ??? h--|  you  |--l ???
      West |       | East
           \-------/
               | South
               j
         (Lake?) Java
                 ^
    Any ideas about the other 3?
    How strange it is, that a fool or a knave, with riches, should be treated with more respect by the world, than a good man, or a wise man in poverty!

  2. #2
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    7,529
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Why vim uses h, j, k and l to move the cursor?

    Hi azzamite.

    Not exactly mnemonics, but the way I learned it was like this:

    Since the keys are close together in a row, put your hand over the keyboard and put each finger over a key:
    • index over the h,
    • middle over the j,
    • ring over the k, and
    • pinky over the l.

    Then it is very easy to understand index (h) as left, and pinky as (l) right.

    Just a thought.
    Regards.

  3. #3
    Join Date
    Sep 2007
    Location
    In here watching you!
    Beans
    Hidden!

    Re: Why vim uses h, j, k and l to move the cursor?

    When Bill Joy created the vi text editor he used the ADM-3A terminal which had the arrows on the HJKL keys. The ADM-3A terminal did not have dedicated arrow keys.
    Last edited by Old_Grey_Wolf; June 25th, 2013 at 08:00 PM.
    Use whatever OS or desktop works for you. Dual boot or use VMs if you want. Backup your computer regularly, and definitely before upgrading, partitioning, or installing an OS.

    No support requests by PM please.

  4. #4
    Join Date
    Mar 2010
    Location
    Metro-ATL; PM free zone.
    Beans
    9,303
    Distro
    Lubuntu 14.04 Trusty Tahr

    Re: Why vim uses h, j, k and l to move the cursor?

    The terminals that I learn on didn't have arrow keys at all. At work, we didn't get terminals with arrows until 1991.

  5. #5
    Join Date
    Jan 2009
    Location
    ::1
    Beans
    2,485

    Re: Why vim uses h, j, k and l to move the cursor?

    Quote Originally Posted by Old_Grey_Wolf View Post
    When Bill Joy created the vi text editor he used the ADM-3A terminal which had the arrows on the HJKL keys. The ADM-3A terminal did not have dedicated arrow keys.
    Ah, cool! ... and here's the proof from http://rollmops.wordpress.com/2006/0...tage-computer/



  6. #6
    Join Date
    Jan 2009
    Location
    ::1
    Beans
    2,485

    Re: Why vim uses h, j, k and l to move the cursor?

    PS:

    And we all know that Gmail uses the same J and K keys for Down and Up through your mails ...

  7. #7

    Re: Why vim uses h, j, k and l to move the cursor?

    Interesting, thanks everyone!
    How strange it is, that a fool or a knave, with riches, should be treated with more respect by the world, than a good man, or a wise man in poverty!

  8. #8
    Join Date
    Sep 2007
    Location
    In here watching you!
    Beans
    Hidden!

    Re: Why vim uses h, j, k and l to move the cursor?

    Quote Originally Posted by sanderj View Post
    Ah, cool! ... and here's the proof from http://rollmops.wordpress.com/2006/0...tage-computer/
    I have to admit I didn't realize the significance of cd ~

    LOL
    Last edited by Old_Grey_Wolf; June 25th, 2013 at 09:05 PM.
    Use whatever OS or desktop works for you. Dual boot or use VMs if you want. Backup your computer regularly, and definitely before upgrading, partitioning, or installing an OS.

    No support requests by PM please.

  9. #9
    Join Date
    Jul 2011
    Location
    /Europe/Netherlands
    Beans
    401
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Why vim uses h, j, k and l to move the cursor?

    Wow, this thread is educational! Didn't know both things (tilde for home folder and origins of HJKL).
    "I believe humans get a lot done, not because we're smart, but because we have thumbs so we can make coffee." --Flash Rosenberg

  10. #10
    Join Date
    Jun 2006
    Location
    Brisbane Australia
    Beans
    713

    Re: Why vim uses h, j, k and l to move the cursor?

    Just as an aside - if I am looking over the shoulders of another software developer and I see him move his fingers over to the arrow keys to navigate around vim then I immediately write him off as a noob ....

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •