sponsor Vim development Vim logo Vim Book Ad

basic Tip #71: Transfer text between two gvim sessions using clipboard

 tip karma   Rating 24/15, Viewed by 2188 

created:   June 4, 2001 11:14      complexity:   basic
author:   Alexey Marinichev      as of Vim:   5.7

If you use gvim, you can transfer text from one instance of gvim into another one using clipboard.  It is convenient to use * (star) register, like this:

In one instance yank two lines into clipboard:
    "*2yy
Paste it in another instance in normal mode:
    "*p
or in insert mode:
    <Ctrl-R>*

 rate this tip  Life Changing Helpful Unfulfilling 

<<running a command on all buffers | Remove unwanted empty lines >>

Additional Notes

[email protected], May 31, 2002 20:10
In gvim, for the "copy to clipboard" command, Ctrl+C works just as well on highlighted text as "*p.
This works for both text in the edit buffer and characters on the command line.

-- Ben
[email protected], May 31, 2002 20:11
Oops, I meant Ctrl+C works like "*y.

-- Ben
anthony, September 22, 2002 18:32
Now if you can only do the same between two vim's runing in xterms!
[email protected], September 22, 2002 18:33
Now if you can only do the same between two vim's runing in xterms!
Pete Zaitcev <[email protected]>, May 1, 2003 11:50
Definitely life-changing, because I really hate pasting with the middle button
into gvim. It pastes under X cursor instead of text cursor, so I always hit
wrong place. And you cannot paste into partially obscured windows,
while you can do it when running vim under xterm. Clipboard does not
have this problem. Clipboard also works well with Mozilla and gnome-terminal.
I only wish gvim adopted Shift-Ctrl-V shortcut as an alternative to "*p.
[email protected], June 3, 2004 7:42
Please fix this tip.  Register * is for the X selection, not the clipboard.  Further reading:

:help x11-selection
http://www.jwz.org/doc/x-cut-and-paste.html
[email protected], July 25, 2004 7:00
See also Tip 66 (https://www.vim8.org/tips/tip.php?tip_id=66) which  works for gvim as well as vim.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge Logo