Linked by Thom Holwerda on Fri 9th Mar 2012 19:11 UTC
General Development "I was reading about vim the other day and found out why it used hjkl keys as arrow keys. When Bill Joy created the vi text editor he used the ADM-3A terminal, which had the arrows on hjkl keys, so naturally he reused the same keys." As interesting as that is, John Graham-Cumming goes even further back in history. "The reason that keyboard had those arrows keys on it was because those keys correspond to CTRL-H, J, K, L and the CTRL key back then worked by killing bit 6 (and bit 5) of the characters being typed." Truly fascinating stuff, even though it's from way before my time (I'm from 1984).
Thread beginning with comment 510182
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE: ...
by Doc Pain on Sat 10th Mar 2012 02:09 UTC in reply to "..."
Doc Pain
Member since:
2006-10-08

So Vim is an example of out dated hardware model enforced in the new one? Good job.


So "Windows" and most of today's programs are also an example of something outdated enforced on the users?

Remember:

Ctrl-Z = undo
Ctrl-X = cut
Ctrl-C = copy
Ctrl-V = paste

See where Z, X, C and V are located on your keyboard (or refer to the US keyboard layout if needed). Looks obvious? You can do some research (simple web search should be sufficient) why this is, and why it still exists today.

To come back why it's actually a good thing to have something "outdated" in vim (and in vi, too): Imagine you have to connect to a UNIX system (or Linux, Solaris, HP-UX or AIX, whatever) that just functions in a minimal state and needs maintenance. The responsible sysadmin has made a mistake and terminal capabilitites don't work at the "high level" you expect, which is required to use the arrow keys. Still you can connect to that system and need to edit a file in the "visual editor" (vi). Whenever you press a cursor key, garbage appears in your terminal session, but the desired cursor movement doesn't happen. But using the HJKL keys will - together with the other "letters only" command keys of vi - to get your job done. In worst case, this is what you want.

But wait, there's more:

Imagine a person with impaired movement of the arm (arm in singular may mean that only one arm is available) or the hand uses a computer. Compare the travelling distance of the fingers from the alphanumeric keyboard section over to the cursor keys. Know that the Escape key is used to switch vi's modes. Now you can easily recognize that having the alternative not to use the cursor keys can be a benefit!

Of course, all those considerations don't apply to mouse-driven users, just as vi doesn't apply to any average person. :-)

Reply Parent Score: 5

RE[2]: ...
by Alfman on Sat 10th Mar 2012 03:14 in reply to "RE: ..."
Alfman Member since:
2011-01-28

Doc Pain,


"Imagine a person with impaired movement of the arm (arm in singular may mean that only one arm is available) or the hand uses a computer. Compare the travelling distance of the fingers from the alphanumeric keyboard section over to the cursor keys. Know that the Escape key is used to switch vi's modes. Now you can easily recognize that having the alternative not to use the cursor keys can be a benefit!"

Personally, I have mixed feelings about VI. I do use it all the time simply because it's available everywhere and that makes it an essential tool. But VI's modes often get in the way of what my brain is thinking and I'd much rather use a stateless interface so my poor escape key can get some rest. To be honest I find ESC to be even less "accessible" than arrow keys are, and while the arrow keys are supported these days, dropping to command mode is still a frequent requirement. Raise your hands, how many people accidentally type or paste text into command mode? I prefer stateless hotkeys because pressing and releasing a modifier has no side effects and I don't have to concentrate on what mode my editor is in (ALT changes focus to menu bar on windows, but CTRL is stateless). I do appreciate the technical limitations under which VI evolved, and I will continue to use it on the console simply out of habit.

Reply Parent Score: 4

RE[3]: ...
by Doc Pain on Sat 10th Mar 2012 04:39 in reply to "RE[2]: ..."
Doc Pain Member since:
2006-10-08

Personally, I have mixed feelings about VI. I do use it all the time simply because it's available everywhere and that makes it an essential tool.


Similar here: I can use when I have to use it, but I prefer a different editor for "normal" use (stateless, as you continue to explain).

To be honest I find ESC to be even less "accessible" than arrow keys are, [...]


Compare its position on "historical" keyboards. The escape key typically has been located on the left, near the number keys (above the Tab key). This changed when the PC became modern (see transition of XT to AT to MF2 keyboard layout).

[...] and while the arrow keys are supported these days, dropping to command mode is still a frequent requirement.


In vi, yes. Many of its "power user functions" are addressed by that mode, whereas the "usual functions" are to be controlled directly.

I prefer stateless hotkeys because pressing and releasing a modifier has no side effects and I don't have to concentrate on what mode my editor is in (ALT changes focus to menu bar on windows, but CTRL is stateless).


I agree. Let me look back when I did use TP (a WordStar-inspired text processing program used on the SCP and DCP operating systems). Control plus one or two letters was the standard way of accessing program functions. Later on, I discovered the editor "joe" and found that it also uses that interface. Together with a good visual representation, this approach is very powerful and grants access to "power user functions". An example: You mark a block with ^KB (block begin) and ^KK (block end), and you can move the block margins intependently, you can even change the block's content while the selection is active (those things are usually impossible in "modern" mouse-driven editors). ^KC copies, ^KM moves and ^KY deletes the block.

But also the editor of the Midnight Commander ("mcedit") focuses on good keyboard support. It uses the programmable function keys which need some "travel distance" for the hands, but can be quickly accessed without visual confirmation. An example regarding blocks: PF3 marks beginning and end of block, PF5 copies, PF6 moves and PF8 deletes it, such as PF5 copies, PF6 moves and PF8 deletes files in the "parent" application. Note that this editor can be used as a stand-alone program, but is known for its excellent integration with the MC.

However, pasting command sequences into the command mode is something that you cannot easily achieve with editors that use hotkeys to address program functions. How would you copy a sequence of key combinations? You need to manually re-type them.

I do appreciate the technical limitations under which VI evolved, and I will continue to use it on the console simply out of habit.


The initial article educated us about why vi initially used HJKL for cursor control. The ability to still use them can be a benefit in "niche situations", but for today's considerations of use, they have (nearly) no meaning than their historical reasons.

Stateful and stateless editors both have their benefits. Use them together. Use them in peace. :-)

Reply Parent Score: 2

RE[3]: ...
by bouhko on Sat 10th Mar 2012 12:22 in reply to "RE[2]: ..."
bouhko Member since:
2010-06-24

I usually map "Caps Lock" to "Escape" (using xmodmap). Caps Lock is useless anyway (at least for me) and this decrease travelling distances significantly.

Reply Parent Score: 2

RE[3]: ...
by viton on Sat 10th Mar 2012 17:37 in reply to "RE[2]: ..."
viton Member since:
2005-08-09

To be honest I find ESC to be even less "accessible" than arrow keys are

I'm not sure about your keyboard, but I can easily press ESC+F on Apple (and pc laptop) keyboards , but can't reach cursor keys without moving a hand.
Also arrow keys on laptop keyboard are too small to be usable.

Reply Parent Score: 2

RE[3]: ...
by Rugxulo on Sat 10th Mar 2012 18:12 in reply to "RE[2]: ..."
Rugxulo Member since:
2007-10-09


Personally, I have mixed feelings about VI. I do use it all the time simply because it's available everywhere and that makes it an essential tool. But VI's modes often get in the way of what my brain is thinking and I'd much rather use a stateless interface so my poor escape key can get some rest.


IIRC, VIM has an easy mode, something like -E option.


To be honest I find ESC to be even less "accessible" than arrow keys are


You can also use Ctrl-[ as an ESC equivalent.

Reply Parent Score: 2

RE[2]: ...
by Neolander on Sat 10th Mar 2012 08:14 in reply to "RE: ..."
Neolander Member since:
2010-03-08

Ctrl-Z = undo
Ctrl-X = cut
Ctrl-C = copy
Ctrl-V = paste

See where Z, X, C and V are located on your keyboard (or refer to the US keyboard layout if needed). Looks obvious? You can do some research (simple web search should be sufficient) why this is, and why it still exists today.

Born with an AZERTY keyboard in the hand, I always figured that it was because it makes sense from a usability point of view to have cut, copy, and paste close to each other.

It's true that if you add cancel to the mix, it starts to feel like a software performance hack.

Reply Parent Score: 1

RE[2]: ...
by zima on Fri 16th Mar 2012 23:52 in reply to "RE: ..."
zima Member since:
2005-07-06

But wait, there's more:

Imagine a person with impaired movement of the arm (arm in singular may mean that only one arm is available) or the hand uses a computer. Compare the travelling distance of the fingers from the alphanumeric keyboard section over to the cursor keys. Know that the Escape key is used to switch vi's modes. Now you can easily recognize that having the alternative not to use the cursor keys can be a benefit!

"A minimum for remote access" or... touchtyping are all well and good, but this^ one might be not so simple, & perhaps you should have looked at the keyboard while typing it. :p

HJKL are basically right in the middle between Esc and cursor keys (for somebody who certainly doesn't type that much in the first place, home row resting place has less meaning) ...plus:

a) cursor keys are typically quite conveniently at least as a semi-separate block, most importantly with no keys below them that can be hit accidentally

b) HJKL & Esc require attention to not hit any of the keys around and below, by that malfunctioning hand.

So as to which one's easier ...yeah, I remember well how it worked when I had my broken hand in a plaster - cursor keys were one of the few totally unaffected, usage-wise (modal things were the biggest issue)

Of course, all those considerations don't apply to mouse-driven users, just as vi doesn't apply to any average person. :-)

Though OTOH even vi (and such) users still fall under http://plan9.bell-labs.com/wiki/plan9/Mouse_vs._keyboard/index.html ...their brains aren't that "non-average" (generally, being very invested into this stuff makes some biases of perception easier - remember, they are felt by the very same organ which invested a lot of effort into given skill)

Edited 2012-03-16 23:54 UTC

Reply Parent Score: 2