How to insert named register from vim commandline

vim

Using vim I have some troubles inserting the value of a specific register using commandline mode.

When in normal mode I can enter the sequence "*p which will put the value of register "* beneath the current line.

If I try to enter the command "*put on the commandline nothing happens. On the other hand, if I just issue the put command the value of the unnamed register is put.

So the question is, how can I put the content of a named register using commandline mode?

EDIT #1

After some additional testing I have found a workaround:

Catch the paste register in a sequence first using qz1"cpq where

qz  -> start recording into register z
1   -> goto line 1
"cp -> put content of register c
q   -> end recording

Using :@z the macro can run to perform the required steps. When used in combination with bufdo:

:bufdo execute "normal @z"

The register can be added as a new line into all opened buffers.

While this is a working method I believe there is a more efficient way to perform the same without the need of a macro.

Best Answer

You can do it with command line version of put:

:put z

The full syntax is :[line]pu[t] [x]. Please see :help :put for more information.

On a side note: Vim geeks' den is this way.

Related Question