I know that in vim I can add
set nocompatible
in .vimrc
to avoid that arrow keys display A, B, C, D in insert mode.
But I'm using vi Version 4.0 (gritter) 12/25/06.
How can I obtain the same behavior?
== EDIT == (1)
I'm using the vi version from Arch Linux which is built from this CVS repository (last commit 24 February 2007) with the following command:
make PREFIX=/usr LIBEXECDIR=/usr/lib/ex PRESERVEDIR=/var/lib/ex \
TERMLIB=ncurses FEATURES="-DCHDIR -DFASTTAG -DUCVISUAL -DMB -DBIT8"
and with theses three patches: fix-tubesize-short-overflow.patch, navkeys.patch and preserve-dir.patch.
== EDIT (2)==
The problems happens in LXTerminal 0.2.0, Termite 10-1, Tilda 1.2.4-1, Terminator 0.98-1 and xterm 320-2 but not in urxvt v9.21 nor in the Linux virtual consoles.
== EDIT (3)==
According to the Single Unix Specification left-arrow, down-arrow, right-arrow, up-arrow correspond to respectively the following capname : kcub1
, kcud1
, kcuf1
and kcuu1
. Comparing terminfo entries from xterm
and rxvt-unicode-256color
for these capterms gives:
$ infocmp xterm rxvt-unicode-256color | grep -E 'kcuf1|kcub1|kcud1|kcuu1'
kcub1: '\EOD', '\E[D'.
kcud1: '\EOB', '\E[B'.
kcuf1: '\EOC', '\E[C'.
kcuu1: '\EOA', '\E[A'.
Modifying the xterm terminfo entry by substituing '\EOD'
, '\EOB'
, '\EOC'
, '\EOA'
by '\E[D'
, '\E[B'
, '\E[C'
, '\E[A'
should solve the problem but is it a good idea? Maybe it will break other programs arrow keys usage?
TERM
in thetermcap
orterminfo
databases is out of synch with the codes produced by the keyboard. The solution is not to change theTERM
, but to find out if yourvi
is linked againsttermcap
orterminfo
, find the keycodes emitted by the keyboard, and fix the corresponding database accordingly. Complaining to the sysadmin might work, too.terminfo
.