Some people don't like to press ESC first to move the cursor
while they're using
vi
. These keymaps change CTRL-h,
CTRL-j, CTRL-k, and CTRL-l to do the same things
during input mode as the commands
h
,
j
,
k
, and
l
do in command mode.
NOTE:
Is your
erase character set to CTRL-h (
5.9
)
outside
vi
? If it is, mapping CTRL-h (usually labeled
BACKSPACE on your keyboard) will change the way CTRL-h
works during text-input mode: Instead of erasing the characters you've
typed since you entered text-input mode, now CTRL-h will move
backwards over what you type without erasing it.
One workaround is to change your UNIX erase character to the DELETE
or RUBOUT key by typing the command
stty erase '?'
before
you start
vi
.
Then your DELETE key will erase what you type and the BACKSPACE key will
jump back over it without deleting.
exrc
|
The lines for your
.exrc
file (
4.9
)
are below: |
map! H [i
map! K [ka
map! L [la
map! V
[ja
" Note: the two lines above map J (LINEFEED)
That last map takes two lines; it's tricky and may not work right on
all versions of
vi
.
No, it isn't a map for CTRL-v, though that's what it looks like.
It maps
J
, the LINEFEED key.
The
V
comes at the very end of its line.
When you're entering that keymap, type CTRL-v and then
press LINEFEED or CTRL-j.
The cursor will move to the start of the next line; type a SPACE
and the rest of the macro.
It's a good idea to add the reminder comment (starting with the comment
character, a double quote (
"
)), on the line below the map.
NOTE:
This map for CTRL-j is pretty obviously something that the
people who wrote my version of
vi
didn't plan for.
For example, look at the mess it makes when I ask for a list of my text-input
keymaps:
:
map!
H H [i
K K [ka
L L [la
[ja
Before you use this map on important files, you should probably test it
carefully.