[ACCEPTED]-How to copy yanked text to VI command prompt-vim

Accepted answer
Score: 182

try to use


where " stands for default register.


Score: 43

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

Score: 21
  • 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 4 relative file path, the line feed will by 3 pasted as well ... i.e. :! touch src/bash/script.sh^M

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

Score: 14

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


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

Score: 5

If it is just a word that you want to copy, you 1 can use <C-r><C-w>

  1. Put your cursor over the word
  2. Then you can type something like :vim <C-r><C-w> *
Score: 3

You can yank to the clipboard using the 5 * named buffer. For instance, this will 4 copy the current line to the clipboard:


So 3 you can copy a line using this, and then 2 paste it with shift-insert in the commandline.

Similarly, you 1 can paste from the clipboard like this:

Score: 2

The clipboard's +, on Mac at least. So you'd 3 write "+yy to yank a line to the clipboard, and 2 "+p to paste. Though you could always use Command-C 1 and Command-V.

More Related questions