[comp.editors] map the space bar

english@uncw.UUCP (Warren R. English Jr.) (02/12/91)

I was wondering if it is possible to map the
space bar in command mode to a key?

I have tried:

:map \  ^D


Is it possible to do this?  If so, How?


Warren English

ecsvax!uncw.uucp!english

az@doc.ic.ac.uk (Alexios Zavras) (02/12/91)

In article <984@uncw.UUCP> english@uncw.UUCP (Warren R. English Jr.) writes:
>I was wondering if it is possible to map the
>space bar in command mode to a key?
>I have tried:
>:map \  ^D
>Is it possible to do this?  If so, How?

Yes, I guess that some people would like the space key to have
a meaning similar to more(1) or other viewing programs...

Although it *is* possible, I would strongly advise against it.
The space key is actually used internally in vi !
If my memory is right, the ~ command, (toggle Upper/lower case)
uses the space to advance to the next character.  So, unless
you also want to move down half a page when toggling cases
(and maybe some other times), do not map the space key.

BTW, if you still want to do it, the escape character is ^V
(control-V), not \ as you tried (and you have to type it
twice to get it).

>Warren English
>ecsvax!uncw.uucp!english

-- zvr -
Alexios Zavras
Usually zvr@theseas.ntua.gr,
but until Feb.15 at az@doc.ic.ac.uk

Dan_Bloch@TRANSARC.COM (02/13/91)

english@uncw.UUCP writes:

> I was wondering if it is possible to map the
> space bar in command mode to a key?
>
> I have tried:
>
> :map \  ^D
>
> Is it possible to do this?  If so, How?

    :map ^V  ^D

where as always ^V represents control-V, entered as control-V control-V.

Happy paging.

Dan

mayoff@cs.utexas.edu (Robert Mayoff) (02/27/91)

In article <5108@lure.latrobe.edu.au> ECSGRT@lure.latrobe.edu.au (GEOFFREY TOBIN, ELECTRONIC ENGINEERING) writes:
>Alexios Zavras (usually zvr@theseas.ntua.gr,
>but until Feb.15 at az@doc.ic.ac.uk) writes:
>> Although it *is* possible, I would strongly advise against it.
>> The space key is actually used internally in vi !
>Hold everything!  Is Alexios accurate in stating that mapping
>a key will change its INTERNAL usage?

Yes, that is absolutely correct.  I for a long time had space mapped to
control-F, so that I could use vi as my pager if I wanted.  It took me quite a
while to figure out why not only tilde (~) but the "s" key wouldn't work!  This
was on SunOS (I don't remember the version, but how much does vi change
anymore?).  Moral: Don't map space.

-- 
/_  rob		<mayoff@cs.utexas.edu>
 /_ Fun things to do with UNIX (#2 in a series):
  / echo "rsh `hostname` -n source eat.cpu &" > eat.cpu; source eat.cpu

ECSGRT@lure.latrobe.edu.au (GEOFFREY TOBIN, ELECTRONIC ENGINEERING) (02/27/91)

Alexios Zavras (usually zvr@theseas.ntua.gr,
but until Feb.15 at az@doc.ic.ac.uk) writes:

> Although it *is* possible, I would strongly advise against it.
> The space key is actually used internally in vi !
> If my memory is right, the ~ command, (toggle Upper/lower case)
> uses the space to advance to the next character.  So, unless
> you also want to move down half a page when toggling cases
> (and maybe some other times), do not map the space key.

Hold everything!  Is Alexios accurate in stating that mapping
a key will change its INTERNAL usage?  As if in defining "+"
(the plus sign) for the C preprocessor (or in Scheme, or in C++)
will prevent the compiler from doing addition INTERNALLY?
(I exaggerate, but I think not by much.)

GT

torek@elf.ee.lbl.gov (Chris Torek) (03/18/91)

In article <5108@lure.latrobe.edu.au> ECSGRT@lure.latrobe.edu.au
(GEOFFREY TOBIN, ELECTRONIC ENGINEERING) writes:
>Hold everything!  Is Alexios accurate in stating that mapping
>a key [in vi] will change its INTERNAL usage?

This is correct.  The list of such keys is:

	<space> $ a i u \ _ r l

(this is for `Version 3.7, 6/7/85.').

The reason is that vi implements a few commands by `pushing back'
some keys you never typed.  For instance, typing `~' makes vi pretend
you typed r, <somechar>, <optional l>, where <somechar> is the
character under the cursor, with its case inverted if it is a letter,
and the <optional l> appears if there is a character after the cursor.

Thus, if you

	:map l h

and type tilde in the middle of a line, vi will flip case and back up.
At the end of the line, vi will flip case and stay put.  At the beginning
of a line, vi will flip case and beep at you.

This is just a symptom of a much greater underlying disease: vi's
internal design is a mess, largely because of the way vi was written.
Sometime in or around the 1970s, Bill Joy & co decided to extend the ed
editor; this became `ex' (the `extended' editor).  Then they added
screen capabilities, invented termcap, added more stuff, ran out of
room on the PDP-11, chipped and hacked to fit, etc.  At some point
Mark Horton took over development.  Eventually he left; since then
there have been only minor changes at Berkeley (no one is doing any
`serious' development anymore).

There is, however, an external design, and vi works as it does not just
`because that was the way Bill Joy set it up'.  For instance, the
original `delete line' command was `d_'; the original yank line command
was `y_'; and so forth.  The concept of `stuttering' on a key came
later.  The external design changes are part of the reason that the
internals are such a mess.
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427)
Berkeley, CA		Domain:	torek@ee.lbl.gov