Arrow Keys In Vim Edit Mode – Funky Characters

Problem

Whilst in vim edit mode, attempting to use arrow keys to navigate within the text results in funky characters appearing in the text.

Explanation

 :help compatible  reveals the following information:

  •  *'compatible'* *'cp'* *'nocompatible'* *'nocp'* boolean  (default on, off when a |vimrc| or |gvimrc| file is found) This option has the effect of making Vim either more Vi-compatible, or make Vim behave in a more useful way.

Solution 1

If you have no .vimrc file, Vim runs in compatibility mode by default. Copy the example .vimrc file into your home directory…

(N.B. Your example vimrc may be somewhere else!)

 cp /usr/share/vim/vimrc.example ~/.vimrc 

 

Solution 2

If you have an existing .vimrc file, compatibility must be switched on in that file.

Find the line in your .vimrc that switches compatibility on, and change it to:  compatible off 

If no such line exists, add the line  compatible off  to your .vimrc file.