18.3. What You Lose When You Use map!
Back in the old days, a
terminal's arrow keys didn't work
during vi text-input mode. To move around in the
file, you pressed ESC and used command-mode commands like
5k and 4w. Since then, lots
of vendors and users have modified vi so that you
can use arrow keys during text-input mode. These days, most people
think the new-fangled way that vi works is the
right way. Here are some reasons to leave the arrow keys alone and do
it the old way instead:
In most cases, the u (undo) command will be
useless after text-input mode because the arrow keymap does several
hidden commands -- and u can only undo the
single previous command. The only
"undo" command that will do much
good is U -- it undoes all changes on the
current line, and it probably won't work if
you've moved off the line since you made the change
you want to undo.
Beginners can get confused by this. They need to learn that
vi is a moded editor -- that you enter text in
text-input mode and make changes in command mode. Movement through
the file is with commands.
When people start using vi and they find that some
motion commands (the cursor keys) work in text-input mode,
vi seems inconsistent.
If your map! runs commands that start with an ESC
(and it almost always will), your ESC key may work more slowly.
That's because every time you press the ESC key,
vi will wait one second (or so) to be sure that
the ESC is just an ESC alone and not the beginning of a
map! sequence. Some versions have changed this,
The fast alternative is to press ESC twice. That rings the terminal
Copyright © 2003 O'Reilly & Associates. All rights reserved.