Skip to content

Making regular vim yank do both yanking and OSC yanking #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
PhilippeCarphin opened this issue Apr 2, 2025 · 0 comments
Open

Making regular vim yank do both yanking and OSC yanking #58

PhilippeCarphin opened this issue Apr 2, 2025 · 0 comments

Comments

@PhilippeCarphin
Copy link

I wanted y and friends to do their regular function but also OSC yank the same text.

It seemed to me that I should have been able to do it with the provided operator but I could concoct a solution that way so I came up with this:

function! MyOSCYankAndNormalYank(type, ...)
    if a:0  " Invoked from Visual mode, use '< and '> marks.
        silent exe "normal! `<" . a:type . "`>y"
    elseif a:type == 'line'
        silent exe "normal! '[V']y"
    elseif a:type == 'block'
        silent exe "normal! `[\<C-V>`]y"
    else
        silent exe "normal! `[v`]y"
    endif
    call OSCYank(getreg("+"))
endfunction

nmap <silent> y :set opfunc=MyOSCYankAndNormalYank<CR>g@
nmap <silent> yy y_
vmap <silent> y :<C-U>call MyOSCYankAndNormalYank(visualmode(), 1)<CR>

by looking at https://vimdoc.sourceforge.net/htmldoc/map.html#:map-operator and the readme of this plugin and some of its code. But I pretty much started with the thing from map-operator example from vimdoc and fiddled with it and got this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant