What a mess I was in lately when I try to repair broken copy/paste feature on vi sessions between my computers. I used to have "+y key combination working for some machines I have, until I realised it was not working anymore.
I tried AI guidance with some progress, but it has taken a lot of time of mine. Different AIs proposed different solutions (only partial indeed) till I reached the latest stable and widespread one.
The solution depends and is easily affected by the programs, their versions and their living environments. Since I have mainly minimal servers with poorer versions of software, it was a bit tricky to find a unique solution applicable to each scenario. But I believe at last I found a simple and working one.
The trick is to use the following on .vimrc for my remote hosts
call plug#begin('~/.vim/plugged')
Plug 'ojroques/vim-oscyank'
call plug#end()
let mapleader = " "
if $SSH_TTY != ''
let g:oscyank_term = 'default'
let g:oscyank_max_length = 0
let g:oscyank_silent = 1
endif
nmap <leader>y <Plug>OSCYankOperator
nmap <leader>yy <leader>y_
vmap <leader>y <Plug>OSCYankVisual
This needs oscyank plugin installed on both peers. Don't forget to push those last nmap lines outside of the if statement, a machine of didn't provided $SSH_TTY that made the code obsolete and took some of my time to recognise the error.
This config lets you use Space y to yank into clipboard..
