Command mode paste
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:
