When working with Vim I often work from multiple monitors and multiple split terminals so I have multiple instances of VIM running at all time. Is there a way to have a persistent shared register that allows me to share the copy paste buffer(Buffer maybe the wrong term here) Is there a setting in VIM or a plugin that would allow me to do this.
And example of the work flow I want is to open VIM and yank text close vim Go to another terminal open VIM and paste that yoinked text.
1 Answer
The persistent shared register is the system clipboard. A similar question has been posted at SO. This is the answer I posted there:
Use the *
(or +
in X Windows) registers to reference the system clipboard. Anything yanked-to or pasted-from those registers can be used to cooperate with other applications:
Cut/Copy examples
"*yy
: copy current line to the system clipbard
gg"*yG
: copy current file to the system clipbard
"*dd
: cut current line to the system clipbard
etc, etc
Paste examples
"*p
: paste the system clipbard
Or in insert mode:
i
Ctrl+r *
Or
i
Ctrl+r Ctrl+p *
(the last one pastes without formatting, useful to avoid those ugly pastes from the OS clipboard where each indented line appears more and more shifted)