You are not logged in.

#1 2022-05-31 15:57:38

shako
Member
Registered: 2021-11-16
Posts: 50

Sharing clipboard between system and Vim

Hi everyone,

as the title suggests, I am looking for a simple way to "share" the clipboard between Vim and the rest of the system.
I can easily copy some text (from, say, a browser page or a terminal window) directly into Vim using keyboard shortcuts while on insert mode, but I would like to be able to do it the other way around, by using Vim's "yank" function.

I've read online about yanking visual mode's selections into the system clipboard (which can be referred as the "+" register), but selecting some text and typing:

"+y

But that seemingly doesn't copy anything to the system clipboard, as pressing "ctrl-v" afterwards doesn't show the yanked text. How can I achieve this? Do i need to refer to an external application, like xclip?

Thanks big_smile

Offline

#2 2022-05-31 16:53:57

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,596

Re: Sharing clipboard between system and Vim

You can use '*' for that, it copies the selection to the clipboard.
BTW. '+' works for me too, it's supposed to be the cut buffer as I read.

Edit:
Hmmm, reading your issue again you don't want to copy a selection but use yank to copy and use ctrl-v in another app like Firefox.
Well, that means you need to use a version that supports '+clipboard +xterm_clipboard'

You can check if you have clipboard support, it should read '+clipboard +xterm_clipboard'
This can be checked with 'vim --version'

You can use the original PKGBUILD and add clipboard support in './configure'

Add these to the vim! build function:

--enable-clipboard
--enable-xterm_clipboard
--with-x=yes

BTW. in my PKGBUILD 'gvim' is removed

Last edited by qinohe (2022-05-31 22:54:02)

Offline

Board footer

Powered by FluxBB