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?

  • Just curious: why not use copy and paste? – Isaac Rabinovitch Sep 4 '12 at 18:25
  • Because in my vimrc file I have custom formatting turned on so when I do so, it'll screw with my indenting. Plus you can only copy and paste what's in the viewable portion of the window if you do that. – bob_cobb Sep 4 '12 at 18:37
  • 1
    Does :set paste not help? – RedGrittyBrick Sep 4 '12 at 18:43
  • @RedGrittyBrick oh wow mind blown. Never knew about that thx! But it still will only allow me to just copy what's on the viewable portion of the screen :\ – bob_cobb Sep 4 '12 at 18:47

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



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.

  • Hmm so I'm trying to get this to work, but it's just not? I'm typing in that sequence exactly. Is this supposed to be entered after I mark something? Forgive my ignorance on using those commands. – bob_cobb Sep 4 '12 at 18:41
  • I think Marco means use "*y'k instead of y'k (then "*p instead of p) – RedGrittyBrick Sep 4 '12 at 18:46
  • @RedGrittyBrick that seemed to work, but only when I was in the same vim instance (so it behaved just like what I was doing before, although I guess it just stored it in a register instead?) so when I switched to another vim instance, it didn't paste that from before. – bob_cobb Sep 4 '12 at 18:53
  • Try + instead of *, as Marco suggests, that should use the system clipboard and therefore work across instances. The * would presumably work if you had multiple windows open in one instance of vim. I don't know if this is O/S dependent. – RedGrittyBrick Sep 4 '12 at 18:55

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


set clipboard^=unnamedplus


:help 'clipboard'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.