Linux Vim and set nocompatible

Every so often I am using a system that inserts a A, B, C, or D when using the arrow keys within the Vim editors insert mode. Vim is for VI Improved. While I did not dig into the exact reasons as to why (terminal emulation?) it happens, it is quite annoying. The fix was simple in my case.

First, test out the command by escaping from the vim editor and type in “set nocompatible”.

Vi set nocompatible Manually

If successful, you will be able to use the arrow keys to move the cursor in Vi insert mode. To make the change permanent to every instance of Vi for the user, we will need to create a user configuration file for Vi.

Creating a new file under your home director with the name “.vimrc” will allow you to set parameters of Vi sessions at the user level.  After saving the file, you should be good to go.

Vi set nocompatible Automatic

/usr/share/vim/vimrc is the location of the system wide configurations if desired.  Additional information about the vimrc configuration file can be found here.


Leave a Reply

Your email address will not be published. Required fields are marked *