How Ubuntu users can get the arrow keys to work in “vi”

Most of you, if you’re lazy like me, will tend to use a normal text editor, like TextMate or gEdit.

You’ll find that after having to SSH in and out of various servers all the time, you’ll be forced to get used to vi, the command line text editor.

If you use Ubuntu (i.e. what everyone that owns a PC should use), you’ll notice that if you press any of the arrow keys (up, down, left, right), you’ll instead get the characters A, B, C, and D. This is in addition to some other unexpected behaviours in Ubuntu’s version of vi.

This is because the default version of vi in Ubuntu is actually vim-tiny.

By installing the normal version of vi:

sudo apt-get install vim

You’ll not only get back the usual behaviours you’d expect from vi, you also get syntax highlighting!


(And if you’re still using Windows, try Ubuntu. It will change your life, I promise.)