How to yank between files?

OneZero picture OneZero · Jul 30, 2013 · Viewed 8.5k times · Source

For example, when I yank some text from vim, then :wq, and open a new file. When I try to paste the text I just yanked, it doesn't work. So how to yank text between files?

Answer

Alexej Magura picture Alexej Magura · Jul 30, 2013

use "+y to send the yanked text to the clipboard, and "+p to paste it into the new file.

So if I have a file named A that contains abcdef and I (in visual mode) select def and then press "+y while in normal mode. I have just copied def to the system clipboard. Now I can open up a file named B and (while in normal mode) press "+p the text def will be pasted into file B.