Command mode paste

3.9
(174)

In past issues, we have covered using the clipboard register. The clipboard register syncs to the system clipboard and is accessible with the * character. To paste from your system clipboard in normal mode, you can can use “*p.

But what about if you’re in command mode? Let’s say you’ve copied some text from another program, maybe regular expression pattern. When you enter command mode with : you can’t use the usual method to paste from the clipboard register. Instead, use Ctrl-r and then press *.

  • <C-r>* – Paste into command mode from system clipboard

You can also use this insert mode. Plus, any of the registers will work including the numbered registers. In practice, I most often use the clipboard register to get data into and out of Vim.

Here’s a quick screencast of this in action. First, I enter command mode to preform a substitution. Then I hold Control and press r then * and the pattern appears, pasted from my system clipboard:

How useful was this post?

Average rating 3.9 / 5. Vote count: 174

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Written by

Andy Libby

28 Posts

Rider of bicycles. Writer of code. User of Vim.
View all posts

Leave a reply

Your email address will not be published. Required fields are marked *