Reputation: 335
So I am editing a UTF8 file in terminal vim and all of a sudden these weird characters come up when I press then navigation keys. So the image attached shows one such character being printed onto the screen after moving up from the end of the file. These guys are merely printed but never saved into the buffer. When that line moves out of view and then back, the character is not printed again. This is a completely random event and never seems to happen at the same location. One exception is I am at the end of the file and happen to press the down key repeatedly.
EDIT: New image for :Set term=cons25
Upvotes: 2
Views: 576
Reputation: 196846
These escape characters appear when Vim is confused about what key presses it receives from the terminal emulator. The arrow keys are received as Escape
followed by a character from A
to D
:
^]0A
is <up>
, ^]0B
is <down>
, ^]0C
is <right>
^]0D
is <left>
.Editing an UTF-8 file has nothing to do with your issue.
Here is what I have in my /.vimrc
to work around that problem:
nnoremap <Esc>A <up>
nnoremap <Esc>B <down>
nnoremap <Esc>C <right>
nnoremap <Esc>D <left>
inoremap <Esc>A <up>
inoremap <Esc>B <down>
inoremap <Esc>C <right>
inoremap <Esc>D <left>
I'm not aware of a better solution.
Upvotes: 1