April 8, 2020

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:


  • for ↓ I get B
  • for ↑ I get A
  • for ← I get D
  • for → I get C
...and it's super annoying.

From my reading, this is how Vi behaves.

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:

vim  ~/.vimrc
set nocompatible

Save the file and this should fix the problem.

fedora / Linux - Add new monitor resolution

Sometimes when you plug in your new monitor, the best fit resolution for it doesn't come out as one of the option in the Display Setting.

Use these commands to add new resolution to your monitor
gtf 1920 1024 60
xrandr --newmode "1920x1024_60.00"  163.83  1920 2040 2248 2576  1024 1025 1028 1060  -HSync +Vsync
xrandr --addmode DP-1 "1920x1024_60.00"