After you have selected the wanted text you can press: y to yank (copy) the content. d to delete (cut) the content. p to put (paste) the content.
In Vim, Copying is done using the y or "yanking". To copy selected text to system clipboard type "+y in Normal Mode. Now you can paste it anywhere else using Ctrl-v .
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:
Esc
:
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
If it is just a word that you want to copy, you can use <C-r><C-w>
:vim <C-r><C-w> *
You can yank to the clipboard using the *
named buffer. For instance, this will copy the current line to the clipboard:
"*yy
So you can copy a line using this, and then paste it with shift-insert in the commandline.
Similarly, you can paste from the clipboard like this:
"*p
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With