Have you ever wondered where the hjkl cursor movement in terminal editors Vi and Vim comes from? I used the movement for quite some time. But when I changed my typing to touch typing, I realised that the placing of the hjkl for cursor movement is a bit odd. When you touch type you place your index fingers while resting on the F and J keys, see this image. These keys also have little bumps so you can feel that your fingers are placed correctly.
Having this in mind, hjkl movement requires the right index finger to jump to the H for moving left. Wouldnt it be better if you can just rest all your fingers on the initial positions for touch typing and still be able to navigate without jumping to other keys? Where does hjkl come from anyway? Let us investigate.
Bill Joy, co-founder of Sun Microsystems, is the original author of the vi text editor. The initial release was 1976. Joy used a Lear Siegler ADM-3A interactive display terminal. See the slightly modified picture by Chris Jacobs of the keyboard of his ADM-3A, CC BY-SA 3.0. I also found the manual of the ADM-3A on the web.
As you can see in the image, the terminal had no other cursor keys. The manual states on page 39, that hjkl are Backspace, Upline, Downline, Forespace. Still, why not jkl;? Also, the Escape key for switching modes was at the location now occupied by the Tab key on the widely used IBM PC keyboard. Ah, that's interesting. Personally, I will stick with the Escape key for switching modes, since I use Tab on a regular basis, but I updated my movement keys to a more reasonable choice. I changed the movement configuration from hjkl to jkl; with the following lines:
noremap ; l noremap l k noremap k j noremap j h noremap <C-W>k <C-W>j noremap <C-W>l <C-W>k noremap <C-W>j <C-W>h noremap <C-W>; <C-W>l
The first block is for cursor movement, and the second is for movement from one split window to the other. I hope you enjoyed this little history lecture about the Vi cursor movement keys. If you have any suggestions for this article, please feel free to write me a mail. Happy hacking!