I managed to arrive at the solution when I tried to use vim with another user (root or a new one). The problem did not occur even though the ~/.vim
folder was a symlink to that of the main user. In the end, the problem was that I had put this in my .bashrc
file:
export TERM=linux
Removing it solved the problem.
The reason I had entered this parameter in .bashrc
was because I noticed a strange behaviour in vim: in INSERT mode, pressing the ESC key and then an arrow key would insert the letters A, B, C or D, depending on the arrow key. As I use this key combination practically all the time when editing a file with vim, this was quite annoying.
Investigating further, I discovered that the reason why this was happening was due to this vim plugin:
tmsvg/pear-tree
To cut it short by setting this parameter:
" Automatically map <BS>, <CR>, and <Esc>
let g:pear_tree_map_special_keys = 0
in ~/.vim/plugin/pear-tree.vim
solves the issue.