In vim, why is 'j' used for down and 'k' for up?

后端 未结 6 728
一生所求
一生所求 2021-02-02 05:21

I\'ve been using vim for many years and have never really thought about it. A friend of mine asked why that is, noting that in our culture, left would usually map to up while ri

相关标签:
6条回答
  • 2021-02-02 05:29

    This is a total guess, but: The Ctrl+J character is the "line feed" character, which on a traditional TTY moves down one line, providing a mnemonic. K was right next to it on a Qwerty keyboard, under the second most commonly used finger on the right hand when in the home position.

    0 讨论(0)
  • 2021-02-02 05:29

    I always thought it was because on the DVORAK layout, j and k are also next to each other. There's not many keys that have this property on both DVORAK and A/QWERTY/Z

    0 讨论(0)
  • 2021-02-02 05:40

    The answer is in the wikipedia entry for vi. Bill joy, who wrote the visual mode of ex - which ended up being vim precursor vi - used a Lear Siegler ADM3A terminal on which the H, J, K, L keys mapped to left, down, up, right - and its been that way ever since.

    Here's the keyboard layout:

    enter image description here

    A couple of other points of note on the ADM3A layout:

    • Left of the Q: the escape key - somewhat handier than where it is on keyboards today, hence a good choice for switching between normal and insert modes.
    • Top right: the 'Home' key doubles as the tilde (~), which subsequently became shorthand for a Unix user's home directory.
    0 讨论(0)
  • 2021-02-02 05:50

    From a user experience perspective, after you open a file, you always move down first and moving down is usually a more frequent operation. Since from left to right is the natural direction for most of us, it make sense to associate the task you perform first or more frequently with the key on the left. You can try to switch the 2 keys and try to tell which way is better. For me, "J" for down is more natural and comfortable.

    0 讨论(0)
  • 2021-02-02 05:54

    It explains it if you run vimtutor in the terminal. It says:

    The h key is at the left and moves left.

    The l key is at the right and moves right.

    The j key looks like a down arrow.

    0 讨论(0)
  • 2021-02-02 05:55

    vimtutor provides the mnemonic that 'J' looks vaguely like a downward-pointing arrow, though that may or may not be the original reason why it was chosen.

    0 讨论(0)
提交回复
热议问题