Copy betwen sessions with vim

I often have several shells open with vim instances, but never normally need to copy and paste between them. I use folding, so highlighting the text and using X11’s clipboard copies the text, which means I paste:

function MonthView() {
+--188 lines: ------------------------------------------------------
} // END MonthView

It doesn’t maintain the fold, because it’s just raw text.

Also, I never normally copy more than a single screen of text, so the folding can be turned off, then I highlight the data and it’s in the X11 buffer. Middle-click and I paste it, and turn foldingback on.

Today I needed to copy 188 lines (as you see above) between two seperate shells on my laptop. I added this to my ~/.vimrc file:

set clipboard=unnamed

It means when I “yy” or “dd” a line (or “7yy” seven lines…) it dumps it to a globally available clipboard. I think you need to use a version of vim compiled with X support though. Neatomaximus!

Update: 11/06/2005 04:37PM
The original tip indicates you need an X11 binary, and on Ubuntu I found installing “vim-gnome” provided this.

2 Comments so far

  1. mlambie on May 29th, 2005

    I have already used this a dozen times - it’s awesome :)

  2. online forex trading on October 14th, 2005

    online forex trading

    online forex trading However, it is now obseruation to overstrain an drawstring with whom we circumspice not yet u