Ubuntu vi Acting Strange

I just installed Ubuntu Server 8 and found vi to be acting strangely (compared to vi on Fedora, CentOS and OSX).

When I use the 'a' command to enter text, pressing the arrow keys results in "C", "D", "B" and "A" to get entered. This makes editing almost impossible..

Am I doing something wrong here?


Solution 1:

You're probably using the vim-tiny editor that doesn't support arrow key navigation in insert mode; Ubuntu 8.04 doesn't have the vim package installed. Install this, and update your default version of vi:

sudo apt-get install vim
sudo update-alternatives --config vi

Select "vim.basic". You may also want to do this for editor (replace vi in the command above with editor) so the default editor called by other programs (like visudo) is also the right version of vim.

I also advise getting in the habit of hitting ESC from insert mode and using hjkl navigation common to Vi/Vim, rather than using the arrow keys.

Solution 2:

another option is to remove vim-tiny:

sudo apt-get remove vim-tiny

and then reinstall vim:

sudo apt-get install vim

Solution 3:

aptitude install vim-full

The first thing I do on a new ubuntu install.

Solution 4:

Try:

:set nocompatible

If it works you may consider putting it into your .exrc (w/o colon).