I am trying to write register 0, into a file.
One method that I have found is to use redir:
redir! /tmp/3
echo 'hello'
redir end
which gives me error invalid argument /tmp/3
and I don't know how to fix that.
Another thing I have found is to use writefile:
let g:the_buffer_raw = getreg("0")
call writefile([g:the_buffer_raw], "/tmp/3", "S")
The problem here is that vim doesn't just do what it says that it does. It does more than just write to the file. It removes the newlines from the register as well. And in the help it does say that it removes the newlines as well, but doesn't say how to change. So it's really just moving my problem from A to B.
I have been searching for hours now, wading through multiple miscellaneous solutions that at the end of the day, aint.
How do I setup a command in the .vimrc file which writes register zero to a file upon request?
:commandto do it. See my EDIT. – Luc Hermitte Jun 15 '20 at 13:47