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.
"+ 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
Hold down the shift key and select text with the mouse cursor.
Text will be copied to the clipboard.
This also works for pasting from the clipboard in to vim.
To be clear, this works for
vim running in a terminal such as
If you are using vim >=7.3.74, then you can actually put this in your vimrc:
Which will automatically use the
+ buffer (the system clipboard) by default. Then to yank (copy), you just use the regular
y command, etc.
I found this behavior to be fairly annoying, though, as commands like
d put the text they operate on into the default buffer, which meant I couldn’t do a fast
dd and paste a line from the internet, for example.