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.

The usual vim yank and paste works only in the same window (but does work across files and close/save commands). Is it possible to make it work across terminals (yank from window in one terminal and paste in another) and if so, how?

share|improve this question
add comment

2 Answers 2

up vote 16 down vote accepted

Probably the simplest thing for you to try is to put set clipboard=unnamed in your .vimrc and restart your vim sessions.

This lets you run yank (e.g. yy) in one window, and put (e.g. p) in another window will just work, because all vim sessions will be sharing the same X selection buffer.

On the downside, your yank buffer will be overwritten as soon as you select some text in any other window of any application.

On the upside, it also means anything you yank in vim can now be pasted into any application by middle clicking.

If you don't like that way, you can type "+ or "* before your yank and put commands, e.g. "+yy to yank a line.

The + forms interact with the clipboard ("+y is like Ctrl+C, "+p is like Ctrl+V).
The * forms interact with the selection buffer ("*y is like left click and drag, "*p is like middle click).

See Making GUI Selections, X11 selection support, and the clipboard and mouse options for details.

share|improve this answer
1  
God I love the middle click. :) –  Dan M. Jan 19 '11 at 13:19
    
set clipboard=unnamed doesn't work for me (I put it in .vimrc and restarted all vim sessions). Unfortunately, nor do the other methods. It looks like my vim is not compiled with x-support. I am using VNC to connect to a linux machine from a windows machine. –  JP19 Jan 20 '11 at 4:55
    
Yes, this method requires X11 support. Run :echo has('x11'), if X support is enabled it will print 1. –  Mikel Jan 20 '11 at 5:17
add comment

If you want to copy an entire file into your target file.

Open your target file in vim.

Put your cursor where you want it and type the following:

:r /path_to_file/file.ext

This will copy an entire file to where your cursor is...

share|improve this answer
add comment

Your Answer

 
discard

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