How to copy yanked text to VI command prompt

try to use

<ctrl+r>"

where " stands for default register.


<C-R>" Will paste default buffer. Alternately, you can use q: to open a buffer for the next command. try :help q:


  • ensure first you are in normal mode by pressing Esc
  • once in normal mode, press :
  • then use the keyboard combination ctrl-r, and then type "

Note: if you are yanking a full line containing relative file path, the line feed will by pasted as well ... i.e. :! touch src/bash/script.sh^M

WILL create a "funny file path" containing the "\r" if you do not remove the last ^M ...


To save you a step of yanking, if your cursor is on the word you want to use in Ex, use:

 <ctl-r><ctl-w>

This eschews yanking to paste into the command line; instead, one pastes the word under one's cursor directly onto the command line. E.g.:

:%s/<ctl-r><ctl-w>/foo/g