I'm trying to copy-paste some text from vim. I'm doing v to enter visual mode, then y once I selected my block.
It appears to copy the text into vim's clipboard, because p will paste it.
But in another program (e.g. Chrome), right-click->paste doesn't paste the correct text. How do I copy text to the correct clipboard?
Best Answer
The following will work only if
vim --version
indicates that you have+xterm_clipboard
feature. If not, you will have to install extra packages or recompile vim with that feature added.There are actually two options for this:
copies to the "usual" clipboard buffer (so you can paste using Ctrl+V, right click and select "Paste" etc), while
copies to the X11 selection - you can paste from this buffer using middle click.
Note that
"*
and"+
work both ways. So if you have selected some text in another application, you can paste it into vim using"*p
and if you have copied some text (using, say, Ctrl-C) then you can paste it into vim using"+p
.