[net.unix] h,j,k,l in vi

mwm@ucbtopaz.CC.Berkeley.ARPA (02/15/85)

[moved from net.unix-wizards, as it (among other things) didn't belong there.]

In article <8242@brl-tgr.ARPA> cottrell@nbs-vms.ARPA writes:
>If you have ever seen an adm-3a terminal you will know where h,j,k,l come
>from. Those keys had arrows on the keys and ^h,^j,^k,^l moved the cursor
>appropriately. Those keys also control the movement of worm(6).

The adm-3 I used didn't *have* arrow keys :-). Yes, I know where those key
choices came from. That's not a good reason to force them on other people.
Sort of like IBM insisting that you have a 32xx to use some of their tools.

>"Those who don not remember history are condemned to forget it."

Great. Now if we can only get those who do remember history to forget it,
so we can do things right.  One of the things that bothers me most about
BSD is the habit of taking a mediocre implementation of a good idea, and
using it over and over again.  To wit: nearly every thing that needs motion
on a screen uses the "vi" command set (plug: see dbell@daisy's *very* slick
life for an example), and far to many things (more than 0) have files that
look like /etc/termcap.

	<mike

ted@usceast.UUCP (Ted Nolan) (02/17/85)

Actually, h, j, k and l are at least half memonic (since ^h is backspace
and ^j is line feed), but that is not the important point.

The point is that you never have to take your fingers off the letter keys
to move the cursor.  I have never used a terminal where the arrow keys were
more easily accessible than h,j,k and l.  In addition, if you tend to use
a variety of terminals (as I do), the placement of arrow keys never becomes
ingrained, but I can usually count on QWERTY.


					Ted Nolan	..usceast!ted
-- 
-------------------------------------------------------------------------------
Ted Nolan                   ...decvax!mcnc!ncsu!ncrcae!usceast!ted  (UUCP)
6536 Brookside Circle       ...akgua!usceast!ted
Columbia, SC 29206          allegra!usceast!ted@seismo (ARPA, maybe)

      ("Deep space is my dwelling place, the stars my destination")
-------------------------------------------------------------------------------

jeff@alberta.UUCP (C. J. Sampson) (02/17/85)

>Great. Now if we can only get those who do remember history to forget it,
>so we can do things right.  One of the things that bothers me most about
>BSD is the habit of taking a mediocre implementation of a good idea, and
>using it over and over again.  To wit: nearly every thing that needs motion
>on a screen uses the "vi" command set (plug: see dbell@daisy's *very* slick
>life for an example), and far to many things (more than 0) have files that
>look like /etc/termcap.

  I have two points to make here:

  1) I feel that the [hjkl] set of cursor keys is very convienent.  I don't
     have to take my hands off of home row to move around, and this speeds
     up my editing.  I don't like using arrow keys for the same reason that
     I don't like using a mouse: it forces me to take my hand off the proper
     place in the keyboard, and then I have to take the time to put it back
     in the proper place and make sure it is aligned correctly.

  2) That fact that the large majority of programs use [hjkl] for cursor
     movement is good.  This is known as consistency.  Since most programs
     use them, you don't have to learn a new set of cursor keys whenever
     you switch from rogue to snake.  I'd rather not fumble around every
     time I start a new program that needs cursor control.  Consistency
     in general makes a lot of things far more easily understandable.
     If you see a file containing several items seperated by colons on
     each line, you can make the assumption that the colon is a delimiter,
     because it was done that way before.  Better one consistent mediocore
     implementation than several hundred good implementations.

=====================================================================
	Curt Sampson		ihnp4!alberta!jeff
---------------------------------------------------------------------
"It looked like something resembling white marble, which was probably
 what is was: something resembling white marble."

jerryp@tektools.UUCP (Jerry Peek) (02/18/85)

In article <726@ucbtopaz.CC.Berkeley.ARPA> mwm@ucbtopaz.UUCP (Praiser of Bob) writes:
>
> >If you have ever seen an adm-3a terminal you will know where h,j,k,l come
> >from. Those keys had arrows on the keys and ^h,^j,^k,^l moved the cursor
> >appropriately. Those keys also control the movement of worm(6).
> 
> The adm-3 I used didn't *have* arrow keys :-). Yes, I know where those key
> choices came from. That's not a good reason to force them on other people.
> Sort of like IBM insisting that you have a 32xx to use some of their tools.

I think there's another reason for using h, j, k, and l: If you're a touch
typist, you'll notice that the keys are on the "home row", where they're
very easy to reach.  It gets so natural to use j and k for up and down
that when I'm using an electric typewriter and want to make a correction,
I end up with a bunch of k's on the paper...

--Jerry Peek, UNIX Training Instructor, Tektronix, Inc.
US Mail:    MS 76-036, P.O. Box 500, Beaverton, OR 97077
uucp:       {allegra,decvax,hplabs,ihnp4,ucbvax}!tektronix!tektools!jerryp
CS,ARPAnet: jerryp%tektools@tektronix.csnet
Phone:      503/627-1603

toby@gargoyle.UChicago.UUCP (Toby Harness) (02/18/85)

> ....                        One of the things that bothers me most about
> BSD is the habit of taking a mediocre implementation of a good idea, and
> using it over and over again.  To wit: ... far to many things (more than 0)
> have files that look like /etc/termcap.

I don`t think all those programs that use termcap-like description files
(lpr, getty, etc.) were done that way because anyone actually liked the
termcap format, but rather because of the very efficient routines for 
reading that format (tgetent, tgetnum, tgetstr, etc.).  I believe the lpr
manual talks about this.

Toby Harness		Ogburn/Stouffer Center, University of Chicago
			...ihnp4!gargoyle!toby

mwm@ucbtopaz.CC.Berkeley.ARPA (02/19/85)

In article <2172@usceast.UUCP> ted@usceast.UUCP (System Programmer) writes:
>Actually, h, j, k and l are at least half memonic (since ^h is backspace
>and ^j is line feed), but that is not the important point.
>
>The point is that you never have to take your fingers off the letter keys
>to move the cursor.

Yup - that's a major advantage, all right. But given that, there are still
"sensible" versus "nonsensical" command layouts. Sensical key layouts fall
into three classes: Geometric, mnemonic and "speed-oriented." Emacs uses a
true mnemonic system:  ^Left, ^Right, ^Forward, and ^Back (in some cases,
^H also works). I can't recall an editor that uses a true geometric system,
but it would look like:

		W (up)
	A (left)	D (right)
		X (down)

Word Star (on some terminals) uses a "speed-oriented" layout, like so:  A
(left), S (up), D (down), F (right). All the primary motion keys are on the
home keys. The next row up (QWER) does line/page, and the lower row (ZXCV)
does word/paragraph, or some such [from memory, so may be wrong].

Now vi, with hjkl, is almost a speed system. Since most other things in vi
are mnemonic, I claim that this puts the vi motion commands in the set of
"nonsensical" key layouts.

Having used vi for two years before switching to Emacs(-like) editors, I
find I prefer the true mnemonic systems. Brief experiments with geometric
and arrow key systems haven't changed my opinion. However, there's been at
least one study with various editing systems that places the speed ordering
(for users in the same experience class) as mice/arrow keys/Emacs [If you
want the reference, send mail and I'll dig it out.]

While on the subject, I'll point out to people who don't know about Emacs
that the motion commands are control keys because Emacs is "modeless."
There is no "insert" command, as all normal graphics characters normally
insert themselves into the buffer. I think that not having to do context
switches to go from inserting to correcting text more than pays for having
to use control keys to move the cursor.

The word "modes" in the above paragraph is quoted because Emacs supports
"modes" that change the meaning of some commands: Examles include "text"
that makes a space character check the line length and insert a newline if
you've exceeded the margin; "Automargin" that works like the vi
"Autoindent"; and "Electric-C" that causes "{" and "}" to change the
margins correctly for "white book" style.

Enough. Try Emacs: you'll like it.

	<mike

howard@cyb-eng.UUCP (Howard Johnson) (02/20/85)

> The point is that you never have to take your fingers off the letter keys
> to move the cursor.  I have never used a terminal where the arrow keys were
> more easily accessible than h,j,k and l.  In addition, if you tend to use
> a variety of terminals (as I do), the placement of arrow keys never becomes
> ingrained, but I can usually count on QWERTY.

I knew someone would like h,j,k,l for the same reasons that I do.
-- 
	Howard Johnson		Cyb Systems, Austin, TX
..!{gatech,harvard,ihnp4,nbires,seismo}!ut-sally!cyb-eng!howard

friesen@psivax.UUCP (Stanley Friesen) (02/21/85)

In article <726@ucbtopaz.CC.Berkeley.ARPA> mwm@ucbtopaz.UUCP (Praiser of Bob) writes:
>
>>If you have ever seen an adm-3a terminal you will know where h,j,k,l come
>>from. Those keys had arrows on the keys and ^h,^j,^k,^l moved the cursor
>>appropriately. Those keys also control the movement of worm(6).
>
>The adm-3 I used didn't *have* arrow keys :-). Yes, I know where those key
>choices came from. That's not a good reason to force them on other people.
>
	But 'vi' *doesn't* force h,j,k,l cursor control on you.
Every version of it that I have ever seen also supports the *real*
arrow keys on terminals that have them.  Why not use them if you
don't like the ADM3-a approach.
-- 

				Sarima (Stanley Friesen)

{trwrb|allegra|cbosgd|hplabs|ihnp4|aero!uscvax!akgua}!sdcrdcf!psivax!friesen
 or
quad1!psivax!friesen

ron@BRL-TGR (Ron Natalie) (02/21/85)

Of couse this causes the "iff bt ibe jet stbdrioe" that rogue players
also suffer from one, because the easiest way to navigate is to move
the fingers of your right hand one key to the right of where they should
be, when you then attempt to type some characters, touch typists get all
screwed up.

-Ron

wombat@ccvaxa.UUCP (02/22/85)

PLATO terminals have arrow keys on the a, q, w, e, d, c, x, and z keys, so
that the direction keys circle the 's' key. The editor is a dumb line
editor, but games (for example, Empire) use those arrow keys.

"When you are about to die, a wombat is better than no company at all."
				Roger Zelazney, *Doorways in the Sand*

						Wombat
					ihnp4!uiucdcs!ccvaxa!wombat

lcc.jbrown@UCLA-LOCUS.ARPA (Jordan Brown) (02/22/85)

	From: mwm@ucbtopaz.cc.UCB-VAX.ARPA
	Newsgroups: net.unix
	Subject: Re: h,j,k,l in vi
	Date: 19 Feb 85 04:04:26 GMT
	Xref: seismo net.unix:3831
	To:       info-unix@BRL-TGR.ARPA

An interesting note, but many of the details are wrong.
	                                                           ...Emacs uses a
	true mnemonic system:  ^Left, ^Right, ^Forward, and ^Back (in some cases,
	^H also works)...

^Forward, ^Back (characters); ^Next, ^Previous (lines).
^Reverse is reverse search; ^L is (for historical reasons) repaint screen.

     ...Word Star (on some terminals) uses a "speed-oriented" layout, like so:  A
	(left), S (up), D (down), F (right)....

Nope, positional:

	scroll up    up     up page
	  ^W         ^E      ^R

left word   left char   right char  right word
  ^A          ^S          ^D         ^F

	scroll down   down   down page
          ^Z           ^X     ^C

These are the standard layouts for these editors.  Note that WordStar, for
instance, starts with a positional layout, and then tries to be mnemonic
for non-movement commands, but fails miserably because most of the interesting
letters are already used up.

I've used all three of these (WordStar, vi, and emacs [ REAL emacs, the
ITS PDP-10 version ]), and currently I'm using vi because it's faster than
emacs and provides most of the functionality I need.  WordStar, of course,
doesn't run under Unix and besides doesn't provide the functionality I like
in an editor.

Why doesn't somebody put together a Unix version of TECO?  Best editor ever;
if you can't do it in a line or two of TECO it's not worth doing anyway.

jordan
---
no, my name doesn't do anything interesting as a TECO macro; both names
(all three, really) contain commands with string arguments, so most of the
characters don't get interpretted.

quiroz@rochester.UUCP (Cesar Quiroz) (02/23/85)

Not to be taken too seriously (nor as a reason to "fix" rogue or vi :-), but

> I think there's another reason for using h, j, k, and l: If you're a touch
> typist, you'll notice that the keys are on the "home row", where they're
> very easy to reach ...
> 

If you're a touch typist, you'd appreciate 'jkl;' more than this off-by-one
non-solution for a non-problem.

Cesar

hugh@BRL-BMD.ARPA (USAFAS) (02/23/85)

The catch is that the home keys for a touch typist are j,k,l,;.  These
keys would be much more easy to use.

		hugh@brl

msb@lsuc.UUCP (Mark Brader) (02/24/85)

I don't use conventional touch-typing (but I typed this sentence without
looking at the keyboard, and used the backspace key only twice along the way);
I don't use conventional touch-typing (but I typed these two lines without
looking at the keys and having to use the backspace only twice), but I can
see the advantage of hjkl on the home row for those who do.  And I don't use
vi either, but that doesn't disqualify me from commenting on hjkl, because
I do play rogue.

I find that all terminals that I have used that have up and down arrow keys
have the up before the down, i.e., either to the left of it or above it.
I must not have ever used the ADM-3a, then, because in the hjkl scheme,
up(k) comes AFTER down(j).  (I CAN think of terminals where control-J was
linefeed and control-K reverse linefeed, but this is nonstandard since
control-K is supposed to be vertical tab.)  I claim that if my experience
is representative then hjkl is braindamaged.

Mild flame: What can you expect from the place that gave us "more", where
the functions of interrupt and quit are reversed, space has the job that
belongs to return, and the standard end-of-file character is an ordinary
command?  ...No counterflames please, I know all this is opinion...

Mark Brader

Conde.osbunorth@XEROX.ARPA (02/25/85)

The real reason for the h,j,k,l mappings in vi is that Berkeley had
nothing but ADM-3a in the early days. If you look on it keyboard, those
keys are the equivalent of the cursor control characters. As a matter of
fact, the early vi had no termcap support...it knew about terminals like
adm-3 by heart. I think that's why there's the :set term=foo
command...then came termcap, and here we are...

Daniel Conde
conde.pa@Xerox.ARPA

guy@rlgvax.UUCP (Guy Harris) (02/26/85)

> 	But 'vi' *doesn't* force h,j,k,l cursor control on you.
> Every version of it that I have ever seen also supports the *real*
> arrow keys on terminals that have them.  Why not use them if you
> don't like the ADM3-a approach.

Because they can be unreliable.  On the few occasions when I use "vi"
(heh heh), I've seen it get confused when I use the arrow keys on my
VT100, so I've adjusted to using h/j/k/l.  I suspect it may be related
to the fact that "vi" does timeouts on input to distinguish escape sequences
from normal typing (but since I rarely use "vi" I don't really care why
it does it).

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy

rad@Mitre-Bedford (02/27/85)

>> 	But 'vi' *doesn't* force h,j,k,l cursor control on you.
>> Every version of it that I have ever seen also supports the *real*
>> arrow keys on terminals that have them.  Why not use them if you
>> don't like the ADM3-a approach.

>Because they can be unreliable.  On the few occasions when I use "vi"
>(heh heh), I've seen it get confused when I use the arrow keys on my
>VT100, so I've adjusted to using h/j/k/l.  I suspect it may be related
>to the fact that "vi" does timeouts on input to distinguish escape sequences
>from normal typing (but since I rarely use "vi" I don't really care why
>it does it).

     The timeout problem that you mention is particularly irksome when
you're working over a terminal network with the delays that it
introduces.  To make "vi" quit worrying so much about escape sequences,
put "set notimeout" in your ~/.exrc file.  I've had this in my .exrc
file for some time, and the only "bad" thing that I've noticed about
this is that I have to hit escape twice before I can force a visual bell.

Dick Dramstad
rad@mitre-bedford.arpa

rpw3@redwood.UUCP (Rob Warnock) (02/27/85)

+---------------
| The real reason for the h,j,k,l mappings in vi is that Berkeley had
| nothing but ADM-3a in the early days. If you look on it keyboard, those
| keys are the equivalent of the cursor control characters...
| Daniel Conde | conde.pa@Xerox.ARPA
+---------------

In all of this dialog about h,j,k,l lately, I have seen no one note the
following (sorry if this is a repeat):

H/J/K/L are "reasonable" for left/down/up/right for the simple fact that

	<cntl>-H == backspace == move left
	<cntl>-J == line feed == move down
	<cntl>-K == vert. tab == move up (on many terminals)
	<cntl>-L == form feed == clear screen [Oh well, can't win 'em all! ;-} ]

That these keys also are (1) on the home row and (2) form a "linearized"
or "flattened" version of the "diamond" cursor-key pattern is an additional
convenience. Note that several game programs which use h,j,k,l for cursor
motions also allow a,s,d,f for left-handed folk.


Rob Warnock
Systems Architecture Consultant

UUCP:	{ihnp4,ucbvax!dual}!fortune!redwood!rpw3
DDD:	(415)572-2607
USPS:	510 Trinidad Lane, Foster City, CA  94404

root@bu-cs.UUCP (Barry Shein) (02/28/85)

An un/poorly documented feature of VI (at least this works on our
4.2bsds and SYSV/3B5 systems) is 'set notimeout' which turns off
that broken feature and *poof* no more

A
A

or whatever your tty transmits for cursor keys. You are right
Guy, it is that attempt to tell you that you hit ESC and didn't
mean it. Why didn't the vi implementors follow what the DEC folks
always do: if you hit ESC, just drop down to the mode line and say:

Are you sure?

[net.joke]

		-Barry Shein, Boston University
		

john@moncol.UUCP (John Ruschmeyer) (02/28/85)

>From: friesen@psivax.UUCP (Stanley Friesen)
>Message-ID: <338@psivax.UUCP>
>
>	But 'vi' *doesn't* force h,j,k,l cursor control on you.
>Every version of it that I have ever seen also supports the *real*
>arrow keys on terminals that have them.  Why not use them if you
>don't like the ADM3-a approach.
>
Not quite- to be specific, 'vi' will use the arrow keys provide that your
terminal transmits some code or another when you press them. Many terminals
(P-E 1200's) treat the arrow keys as a local command and do not send them
to the host.

  Even if you terminal *does* send a code for each of its arrow keys, you
may still not be able to use them in 'vi'.  One of the arrow keys on my
TRS-80 Model 100 sends a code which is apparently reserved in 'vi'. (I
think it is ^_ .) Whenever I use it, I get a 'no tags file' error message.


-- 
Name:		John Ruschmeyer
US Mail:	Monmouth College, W. Long Branch, NJ 07764
Phone:		(201) 222-6600 x366
UUCP:		...!vax135!petsd!moncol!john	...!princeton!moncol!john
Silly Quote:
		"Everybody knows in the second life,
		    We all come back sooner or later.
		 As anything from a pussy cat,
		    To a man-eating alligator."

robert@gitpyr.UUCP (Robert Viduya) (03/01/85)

><
Posted from  friesen@psivax.UUCP (Stanley Friesen)
>
> 	But 'vi' *doesn't* force h,j,k,l cursor control on you.
> Every version of it that I have ever seen also supports the *real*
> arrow keys on terminals that have them.  Why not use them if you
> don't like the ADM3-a approach.

Why not?  Because a lot of terminals have cursor keys that conflict with
vi's keystroke commands.  Take for example one of the Televideo type term-
inals.  The cursor right key sends a ^L and the cursor down sends a ^V.
Vi uses a ^L as a 'redraw screen' command and a ^V as a 'quote next char'
command.  What does vi do in this case?  It preempts the action normally
attached to the keys in favor of the cursor keys, leaving the poor user
without a redraw screen or quote next.  Then there's the ADDS Regent 25
which uses a ^Z as one of it's cursor control keys.  Under 4.2BSD, vi isn't
built to catch that.

			robert
-- 
Robert Viduya
Georgia Institute of Technology

...!{akgua,allegra,amd,hplabs,ihnp4,masscomp,ut-ngp}!gatech!gitpyr!robert
...!{rlgvax,sb1,uf-cgrl,unmvax,ut-sally}!gatech!gitpyr!robert

robert@gitpyr.UUCP (Robert Viduya) (03/03/85)

><
Posted from  rpw3@redwood.UUCP (Rob Warnock)
> H/J/K/L are "reasonable" for left/down/up/right for the simple fact that
> 
> 	<cntl>-H == backspace == move left
> 	<cntl>-J == line feed == move down
> 	<cntl>-K == vert. tab == move up (on many terminals)
> 	<cntl>-L == form feed == clear screen [Oh well, can't win 'em all! ;-} ]

Televideo terminals (and their look-a-likes) use ^L as a cursor right.

			robert
-- 
Robert Viduya
Georgia Institute of Technology

...!{akgua,allegra,amd,hplabs,ihnp4,masscomp,ut-ngp}!gatech!gitpyr!robert
...!{rlgvax,sb1,uf-cgrl,unmvax,ut-sally}!gatech!gitpyr!robert