I'm trying to programmatically record a macro (using :let @m=
rather than qm
). In vim, I executed:
:let @m = ':retab^M'
where ^M
is typed as ctrl+V, Enter. I expect the buffer to contain exactly what is written above, but it also contains a newline at the end, and when the macro is executed, my cursor moves down by one line. If I populate @m
with the q
record function, this problem does not occur.
How can I programmatically set a register to contain a ^M
but not an extra newline? Note that :let @m=":retab\<cr>"
gives the same result.
To elaborate: I expect the @m
to contain ':retab^M' or ':retab\n' but it actually contains: ':retab\n\n' with an extra newline. Or to say it another way, :let @m = ':retab^M'
and qm:retab ENTER q
should give the same result (the identical macro in register m
), but they differ by a newline character. (The result is the same on Windows and Linux.)