I have noticed a strange behaviour of Vim that does not correspond to what I read online. For example the <F1>
key inserts a ‘P’ in the line above, <F2>
a Q, <F3>
an R, <F4>
an S and <F5>
toggles the case.
I tried running:
vi -u NONE text
but I still get the same behaviour. If I run:
:verbose map <F1>
I get:
No mapping found
What could it be?
# LANG=C aptitude search ~i~nvim
i vim 2:9.1.0861-1 - Vi IMproved - enhanced vi editor
i vim-common 2:9.1.0861-1 - Vi IMproved - Common files
i A vim-nox 2:9.1.0861-1 - Vi IMproved - enhanced vi editor - with scripting languages support
i A vim-runtime 2:9.1.0861-1 - Vi IMproved - Runtime files
i A vim-tiny 2:9.1.0861-1 - Vi IMproved - enhanced vi editor - compact version
I did as suggested by romainl. Inside Vim:
^[OP^[OQ^[OR^[OS^[[15~
On my terminal (xfce4-terminal):
^[OP^[OQ^[OR^[OS^[[15~
I, too, have the feeling that it has nothing to do with Vim but is some setting that I recently changed. The problem is that I don't know where to look.
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.