viki.omega9
viki.omega9

Reputation: 335

Vim UTF8 characters in terminal

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.

image

EDIT: New image for :Set term=cons25

image2

Upvotes: 2

Views: 576

Answers (1)

romainl
romainl

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

Related Questions