what's the difference between these two methods?
p
inserts the content of a register
as it is, regardless of the encoding, but CTRL-R CTRL-R
encodes sequences of bytes before inserting them.
Explanation
Special key combinations, such as Ctrl+→, are translated
into terminal keycodes like ^[[1;5C
, then into vim keycodes like <C-Right>
,
and finally into a sequence of bytes starting with 0x80
like <80><fd>V
(<80>
is 0x80
)
[1]
[2]
[3]
[4]
[5].
This is a special case where the vim keycode is different than the terminal keycode
[6].
After assigning the register q
like this:
let @q="\<C-Right>"
the sequence of bytes is what's actually saved:
:registers q
Type Name Content
c "q <80><fd>V
Press ENTER or type command to continue
If I went to insert mode and put this sequence by hand as Unicode code points
[7]
[8]
[9] (V
is 0x56
here)
- Ctrl+V u0080 for
<80>
- Ctrl+V u00fd for
<fd>
- Ctrl+V u0056 for
V
This is what I would get:
<80>ýV
which is the same result as the one I would get if I pressed
Ctrl+r Ctrl+r q in insert mode.
I have no idea what <c2>
is
If the cursor is moved on the opening angle bracket <
in the previous output:
<80>ýV
and then press g8
in normal mode, this is the output I'd get [10][11]:
c2 80
These are the hexadecimal numbers for the two-byte UTF-8 character under the cursor; so the <c2>
is the first byte of the two.
As a final note, what follows is the output of "qp
in normal mode:
<80><fd>V
If I again move the cursor on the first <
and press g8
the output would be different:
80
because that's not a UTF-8 character but just a binary one.
Thanks to all the Vi and Vim community (including you) who made this answer possible. I hope this answer is useful.