Assuming you want to put the register contents in a buffer use Normal mode command sequence "rp
. That'll produce the same thing as you'd see with :reg r
.
The thing with getreg()
is that it doesn't attempt to output printable characters. For example, if register "r" contains a backspace and you send getreg('r')
output to a buffer (e.g. with <C-R>=getreg('r')
while in Insert mode) then the backspace will actually move the cursor back.
But if you paste the register directly you'll see printable translations of everything. (Example: for me backspace is displayed as <80>kb
.)
Note that there is a function that does similar translation to printable characters on whatever you pass to it called strtrans()
. Modifying the Insert mode command mentioned above to be <C-R>=strtrans(getreg('r'))
will display the same thing as "rp
.