How can I execute multiple lines of Vim Ex commands from a register? For example, if I copy some mappings I want to try, how can I execute these lines within the current buffer, from the register I've copied them to?
nnoremap <leader>b :tab split<cr>
nnoremap <buffer> ...
...
I've tried using :
followed by <ctrl-r>"
(assuming the lines are in the unnamed register) to paste the lines in command line mode, followed by hitting <cr>
. The lines that are pasted appear to be separated by ^M
, as opposed to newlines. The approach does not work.
I've also tried using q:
to open the command-line window, followed by <ctrl-r>"
, and then hitting enter, but this only executes the current line, rather than all lines I've pasted.
I could paste the lines into a file, and then source that file, but I am looking for an alternative, more direct approach.
You can use :@"
to run the contents of the default register as an Ex command.
See :help :@
.