MacVim: share named registers across windows?

2019-05-10 10:40发布

问题:

I want to share named register buffers across MacVim windows (as I would across buffers within a single instance). In other words, let's say I mark a position, m, and go somewhere else:

I yank some text into register a, from current point to 'm: "a'm

Then I go to another window (no, I dont mean another split view in the same window...) and want to paste: "ap

What is a good way to share named registers across all instances?

回答1:

You should take a look at the YankRing plug-in. It "maintains a history of previous yanks, changes and deletes." I think it will do what you want.



回答2:

The different top-level windows of MacVim are different instances of Vim with their own state, which makes this hard. As far as I can tell, you have two options:

  1. Use the "+ or "* registers, which both use the Mac system clipboard. (As an aside: in X11 they are different, but all other GUIs treat them the same). MacVim has the standard Cmd+X/C/V bound to use "+. Unfortunately that only gives you one shared buffer.

  2. Keep a text file with your registers in it, as explained by max at Make vim yankings global via a shared text file.



回答3:

Top level windows have use different vim instances, so they don't share the same register, but different tabs do share the same registers.

So as a quick and dirty simple solution, open the files in different tabs of the same window to share their named registers.