Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 right would map to down, making the vim keys backwards. I understand that they are on the home row, meaning that you do not have to move your fingers anywhere to hit them, but that's a different point altogether. Basically, my question is: does anyone know why these keys were given their present purposes? It would be great if you could point me to some documentation on the decision as well.

like image 263
geowa4 Avatar asked Jul 01 '11 22:07

geowa4


People also ask

Why is vim HJKL?

Vim uses hjkl because vi did. Vi used hjkl because its creator's keyboard didn't have physical cursor keys. Instead, the arrows were printed on the hjkl keys.

What is key bindings in vim?

Probably one of our top feature requests. By Vim, I mean literally Vim, the command-line text editor. And by bindings, I mean keyboard commands that do specific things in the editor. Fortunately for us, CodeMirror, the code editor library we use, has a special add-on for Vim bindings.

What is N in vim?

n is a default mapping in vim. In particular, n repeats the last search from the cursor's position down. You recently searched for "final" so that's what it searched for. In general, it is pretty easy to find out what a key does with :help <key> while in vim.


1 Answers

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.
like image 181
martin clayton Avatar answered Oct 07 '22 02:10

martin clayton