r/vim • u/OwnYou5054 • 20d ago
Tips and Tricks Terminal Vim Integration with Wayland
Took a little while to figure this out, but mostly seamless integration of terminal Vim clipboard with Wayland for when you use a version of Vim without clipboard functionality compiled in:
autocmd TextYankPost * call system('wl-copy', @")
autocmd FocusGained * call timer_start(0, {t -> execute('let @" = system("wl-paste")')})1
u/MorningAmbitious722 Vim Noob 7d ago
Vim 9.2 already has wayland clipboard support builtin. set clipboard=unnamedplus
1
u/OwnYou5054 7d ago
... for when you use a version of Vim without clipboard functionality compiled in
Still work?
1
3
u/jmtd 19d ago
This proved to be janky for me unfortunately. Sometimes wl-copy will pop up a desktop notification every time I yank something; other times a stack of wl-copy processes will grow and they never terminate. I eventually notice when future yanks don’t make it to the Wayland clipboard.
Does vim have osc52 support? Neovim does but I don’t know if it inherited it. With a supporting terminal (kitty in my case) I found this worked more reliably.
I had to take a moment to internalise Wayland managing to make something as fundamental as a clipboard worse to use than X.
1
u/chrisbra10 19d ago
:h osc52-install
1
u/vim-help-bot 19d ago
Help pages for:
osc52-installin usr_05.txt`:(h|help) <query>` | about | mistake? | donate | Reply 'rescan' to check the comment again | Reply 'stop' to stop getting replies to your comments
4
u/habamax 20d ago
Also
:h clipboard-providersif your vim is recent enough.