Copy to both X11 clipboards from vim

vimx11

As far as I can see, with VIM I can choose between

  • set clipboard=unnamed – yank to X11's primary selection buffer (middle-mouse button paste)

  • and set clipboard=unnamedplus – yank to to X11's clipboard buffer (Ctrl-V paste in most GUI apps)

Is there a way to make it do both at the same time?

I usually use middle-mouse paste but that doesn't work everywhere so I'd like my selections to also be available in the clipboard buffer.

(I'm aware I could do "+y but I'd like to have that automatically)

Best Answer

For yanks, Vim supports setting both unnamed and unnamedplus:

:set clipboard=unnamed,unnamedplus

From :help clipboard-unnamedplus:

      When "unnamed" is also included to the
      option, yank operations (but not delete, change or
      put) will additionally copy the text into register
      '*'.
Related Question