Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
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

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
    
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

or

set clipboard^=unnamedplus

See

:help 'clipboard'
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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