PDA

View Full Version : Why vim uses h, j, k and l to move the cursor?



azzamite
June 25th, 2013, 07:07 PM
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:


???
k
| North
/-------\
| |
??? h--| you |--l ???
West | | East
\-------/
| South
j
(Lake?) Java
^

Any ideas about the other 3?

papibe
June 25th, 2013, 07:38 PM
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.

Old_Grey_Wolf
June 25th, 2013, 07:54 PM
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.

TheFu
June 25th, 2013, 08:11 PM
The terminals that I learn on didn't have arrow keys at all. At work, we didn't get terminals with arrows until 1991.

sanderj
June 25th, 2013, 08:31 PM
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/05/01/vintage-computer/


http://rollmops.files.wordpress.com/2006/04/Lear_Siegler-ADM3A_1805.jpg

sanderj
June 25th, 2013, 08:37 PM
PS:

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

azzamite
June 25th, 2013, 09:02 PM
Interesting, thanks everyone!

Old_Grey_Wolf
June 25th, 2013, 09:02 PM
Ah, cool! ... and here's the proof from http://rollmops.wordpress.com/2006/05/01/vintage-computer/

I have to admit I didn't realize the significance of cd ~

LOL

Erik1984
June 25th, 2013, 09:37 PM
Wow, this thread is educational! :P Didn't know both things (tilde for home folder and origins of HJKL).

markbl
June 25th, 2013, 11:36 PM
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 .... ;)