[ACCEPTED]-How to copy yanked text to VI command prompt-vim
try to use
<ctrl+r>"
where " stands for default register.
0
<C-R>"
Will paste default buffer. Alternately, you 2 can use q:
to open a buffer for the next command. try 1 :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 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
...
To save you a step of yanking, if your cursor 4 is on the word you want to use in Ex, use:
<ctl-r><ctl-w>
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.:
:%s/<ctl-r><ctl-w>/foo/g
If it is just a word that you want to copy, you 1 can use <C-r><C-w>
- Put your cursor over the word
- Then you can type something like
:vim <C-r><C-w> *
You can yank to the clipboard using the 5 *
named buffer. For instance, this will 4 copy the current line to the clipboard:
"*yy
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:
"*p
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
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.