I have a problem on copying text between different instances of Vim on Wayland (exactly I use Sway window system). Natively it's not supported, because Wayland doesn't have a clipboard itself. But it can be installed. Following the instructions from several sources in internet I did the next steps:
1)Install package wl-clipboard.
2)Modify ~/.vimrc by adding the following lines:
xnoremap "+y y:call system("wl-copy", @")<cr>
nnoremap "+p :let @"=substitute(system("wl-paste --no-newline"), '<C-v><C-m>', '', 'g')<cr>p
nnoremap "*p :let @"=substitute(system("wl-paste --no-newline --primary"), '<C-v><C-m>', '', 'g')<cr>p
Then it's supposed to do copy/paste operations to/from + register between multiple instances. But in my case it doesn't. And when I use it in another terminal it pastes either lines from some previous session or nothing.
It's interesting thing, but after I had modified above lines this way:
xnoremap y y:call system("wl-copy", @")<cr>
nnoremap p :let @"=substitute(system("wl-paste --no-newline"), '<C-v><C-m>', '', 'g')<cr>p
made it just for curiosity and it started to work between instances using simple y/p.
So I can guess that I use register operations somehow not properly, then I tried it making "+y the "+p on some lines within one file and it worked correctly (but still not in separate files)
So I think such behavior is weird and makes me think I don't understand Vim clipboard mechanism in right way.
Please reply if you had same issue or correct me If I do something wrong.
Vim 8.2
Linux 5.10.16-arch1-1 x86_64
Terminal Alacritty.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
xnoremap "+y y:call system("wl-copy", @")
I think Vim sees the " as a comment character. I wonder why you didn't get a no mapping found message.
I decided to stay with second variant:
xnoremap y y:call system("wl-copy", @")<cr>
nnoremap p :let @"=substitute(system("wl-paste --no-newline"), '<C-v><C-m>', '', 'g')<cr>p
Because:
I decided to stay with second variant:
xnoremap y y:call system("wl-copy", @")<cr>
nnoremap p :let @"=substitute(system("wl-paste --no-newline"), '<C-v><C-m>', '', 'g')<cr>p
Because:
—
Closed #7922.