Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to yank between files? [duplicate]

Tags:

vim

yank

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?

like image 609
OneZero Avatar asked Jul 30 '13 21:07

OneZero


2 Answers

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.

like image 177
Alexej Magura Avatar answered Oct 01 '22 08:10

Alexej Magura


Don't quit the editor after writing with :wq

Instead, just write the file with :w and then edit the new file with :e file. Or Edit both at the same time by splitting with :sp file and ^W to switch between the screens.

like image 28
evil otto Avatar answered Oct 01 '22 08:10

evil otto