0

So I have a lot of lines to copy from one file (open in one instance of gvim) to another file (open in another instance of gvim) and I'm using ex commands. So I tried doing the usual

:0,164ya

and then going to the other file and doing

:pu

and I also tried

:+0,164ya

and then

:+pu

but neither worked. I also tried using p instead of pu. Anyone have any idea on how to do this?

SilentDev
  • 20,997
  • 28
  • 111
  • 214

2 Answers2

1

Use the "+ or "* registers:

:0,164y +
:put +
romainl
  • 186,200
  • 21
  • 280
  • 313
1

Vim doesn't sync its register contents across Vim instances. Therefore, you have to use a shared data store like the system's clipboard (register "+), or a separate file (:[range]w /tmp/file, followed by :r /tmp/file).

If you really need to transfer multiple register contents at once (where the approaches above become tedious), you have to explicitly sync the register contents via the viminfo file that persists them (among all other history).

In Vim 1:

:[range]yank a
:wviminfo

In Vim 2:

:rviminfo!
:put a
Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324