vim arrow keys adds characters in editor

I had this problem sometimes on my application server, which can sometimes be old machines. When I tried to use arrow keys in insert mode in vim editor the following characters are being inserted in the editor:


<ul><li>for ↓ I get B</li><li>for ↑ I get A</li><li>for ← I get D</li><li>for → I get C</li></ul><div>…and it’s super annoying.</div>
<div>From my reading, this is how Vi behaves.</div><div><div>
</div><div>However, VIM is the successor to Vi. By default, it set to be in Vi-compatible mode, which includes this behavior for the arrow keys.

To remove the compatible mode, create a file named .vimrc in home directory add this line to the top of the file:</div><blockquote class="tr_bq">
vim  ~/.vimrc
set nocompatible</blockquote><div>
</div><div>Save the file and this should fix the problem.</div></div>