Package: nvi
Version: 1.81.6-8.1
Severity: normal
By default, nvi sets up some key mappings for cursor keys and some
other editing keys. The key strings appear to be taken from terminfo,
and they're mapped to sequences that roughly implement the keys' nominal
editing actions. There needs to be some way to suppress these default
mappings, preferably by a command in ~/.exrc, in order to prevent them
damaging the interactive experience.
The remainder of this bug report details how the default mappings are
a problem and that there currently isn't any way to suppress them.
You can skip this if you're already clear on these matters.
The default mappings are mostly OK (as in, don't interfere with anything)
for the command map. In the input map, however, they tends to screw up
the use of Esc to terminate input. For example, I get this by default
in an xterm:
:map!
^[OA ^[ka cursor up
^[OB ^[ja cursor down
^[OC ^[la cursor right
^[OD ^[ha cursor left
I'll leave aside the issue of these target sequences being very poor
implementations of arrow actions, and the fundamental problem that arrow
actions make no sense in the middle of a text parameter to an editing
command. These mappings cause a practical problem by making the ^[ byte
ambiguous, when seen in the input while reading text. When I press Esc,
rather than immediately end the text input, nvi waits for half a second
or so to see whether there are more bytes following that would indicate
that I'd pressed an arrow key. This pause damages the interactivity of
vi, by denying immediate feedback.
Furthermore, starting from text input, the actual key sequence
Esc-O-anything *is valid*. It ends input, then opens a new line above
the current one, and begins text entry on the new line. The mappings make
these sequences as a whole ambiguous: whether Esc-O-A (for example) gets
its proper behaviour or the fake-up-arrow behaviour depends on the timing
with which it is typed. I don't often run into this, but it has happened.
So I'd like to not have these confounding entries in the input map.
Obviously, in a running nvi instance I can manually remove them one
by one, by entering unmap commands. That's very cumbersome. I should
be able to automate this by putting the unmap commands in my ~/.exrc,
but that strangely doesn't work. If I have this in my ~/.exrc:
unmap! ^[OA
unmap! ^[OB
unmap! ^[OC
unmap! ^[OD
(real escape characters, not hat-bracket), then on startup vi complains:
"^[OA" isn't currently mapped
/home/zefram/.exrc, 10: Ex command failed: pending commands discarded
and yet the default mappings are in full effect. Strangely, I *can*
replace the default mappings with other mappings in ~/.exrc, by using
the map command. In that case there's no error and the .exrc mappings
are in effect in place of the default mappings. (They take precedence
key-by-key; any key not explicitly mapped in .exrc gets its default
mapping.) I tried mapping the escape sequences to themselves: that
fixes the rare Esc-O-A problem, but doesn't avoid the pause.
If unmap commands in ~/.exrc took effect in suppressing the default
mappings, as map commands do, that would be a big step forward. But it's
actually not a satisfactory solution, as alluded to by the error messages
shown above. Once the first unmap command on a not-mapped key sequence
is seen, the rest of the .exrc is ignored. This is a problem because the
sequences that get default mappings aren't fixed, but depend on terminfo.
For example, in rxvt the arrow keys send ^[[A et al instead of ^[OA et
al, and terminfo knows it. If I use both terminal types, it would be
an obvious strategy to put unmap commands into ~/.exrc for both sets
of default-mapped sequences. But that won't work, because the unmap
commands for the sequences that the present terminal doesn't use will
be treated as an error, and if the error is caused by the first set of
unmap commands then the correct set won't get to run.
Even apart from the error issue, having to tell .exrc about the escape
sequences for every terminal I ever use is a messy way to go about this.
In practice it'd be kinda workable, because most terminals send either
the ^[[A or ^[OA set, but it'll always fall down on the occasional use
of an unconventional terminal not previously used.
So it would be much better to have a command in .exrc that doesn't need
to vary according to terminal. Also preferably a single command to
affect all the keys. I'd like to have a command that says "don't apply
default mappings". Either one command for each map (command and input),
or one for both.
-zefram
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]