|
Chapter 31 Creating Custom Commands in vi
|
|
Back in the old days (when bread cost five cents and my grandfather was
just a boy...) 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.
In fact, we show you how to do it yourself in articles
31.2
and
31.13
.
These days, lots of folks think the newfangled 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.
The only "undo" command that will do much good is
U
-it undoes all
changes on the current line, and it doesn'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!
ped sequence.
Some vendors have changed this, though.
The fast alternative is to press ESC twice.
That rings the terminal bell, though.
|
|