vim tip: Fix the cursor keys echoing characters in insert mode | Comments (4)
Posted in Linux/Unix on 15th October 2006, 2:01 pm by Stuart
Occasionally you’ll log into a remote server and find that the cursor keys echo characters when you are in insert mode using vim. Here’s how to resolve it by modifying your vimrc configuration file:
vim ~/.vimrci(Enter insert mode)set t_ku= (now type Ctrl-V and press cursor up)set t_kd= (now type Ctrl-V and press cursor down)set t_kr= (now type Ctrl-V and press cursor right)set t_kl= (now type Ctrl-V and press cursor left)- Press escape to exit insert mode
Ctrl-zz(Saves the file and exits vim)

After step 6, press Esc to get into command mode (beep mode) first, and then do Ctrl-zz to save and exit.
Well spotted Mike, I’ve amended the instructions. Thanks.
I’ve seen a lot of times that this is caused by vim running in compatible mode. You can fix this by editing ~/.vimrc and adding the following line:
set nocompatible
Jonathan is correct this is definitively fixed with adding
set nocompatible
to your ~/.vimrc file or even adding:
:set nocompatible
to your /usr/local/share/vim/vimrc file (this is the default file for system wide configuration. Thanks Jonathan, it worked great for me.