How can I copy text in one screen window running vim and paste it to another without traditional copy and paste?

I'd like to essentially yank text y'k and mk or yy in one instance of vim in one screen tab and paste it into another instance of vim in a different screen tab without having to select the text with my mouse and ctrl+c/ctrl+v.

How can I do that?


You can either use the register * (middle mouse paste) or + (“normal” clipboard):

"*y
"+y

Edit:

To make it more clear, the commands I wrote above assume that you marked some text visually. To copy the current line you can for example do: V"*y and then you can paste in every application with the middle mouse button. Or you can use V"+y and paste with ctrl-v or whatever shortcut you have configured to paste.


In addition to what Marco wrote, you can add the following to your vimrc to use the "* or "+ register in parallel with the unnamed register so that, for example, text yanked with yy will automatically go to the "* or "+ register.

set clipboard^=unnamed

or

set clipboard^=unnamedplus

See

:help 'clipboard'