I've the following text copied to the "0 register
test
test
If I want to copy the content of the
"0register to the"aregister I do:let @a=@0Then, if I paste the content of
"aregister I obtaintest testNow, to paste the content of the
"0register to the"aregister I do:let @a="and then
<C-r>0, and the result is this:let @a="test^Mtest^M"Then I paste the content of
"aregister ("ap) and I obtaintest^Mtest^M
Why are the results not equal?
Specifically, why the newline characters are written literally and not interpreted in the second case?
From
:help c_ctrl-r:--- EDIT ---
<C-r>0inserts the content of"0as if you typed it. Since"0contains a<CR>(two, actually, but the second is irrelevant):that
<CR>would be typed just as you would have typed it, which would result in the command being executed before the typing is finished:which would throw
E114because of the missing".The compromise, here, is to insert a literal
^Minstead of typing<CR>to allow the command-line to be finished.You don't have that problem with
:let @a = @0because there is no typing and no I/O involved: it's just values being passed around.