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?


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.


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.

  • Thanks, exactly what I was looking for. I was searching for and reading all I could find on :help put but did not think of :help :put – Lambert Jul 17 '15 at 16:26
  • 1
    One tip that may be helpful in the future is, when you type a :help command (or part of one), you can press Ctrl-D to see a listing of the possible completions. Typing :help put and then typing Ctrl-D shows :put along with many other related options. – Wildcard Sep 27 '15 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.