1

I would like to swap content between my system clipboard and a Vim register. I am missing one last piece of the puzzle, indicated below. Any thoughts?

map <Leader>" :call SwapBuffer()<CR>
function! SwapBuffer()
    let @t=@"                   "t := v
    call system("wl-paste", @") "v := c  <- out-of-order. have also tried non-special reg.
    call system("wl-copy", @t)  "c := t
endfunction
0

Solved:

map <Leader>" :call SwapBuffer()<CR>
function! SwapBuffer()
    let @t=@"                   "t := v
    let @" = system("wl-paste") "v := c
    call system("wl-copy", @t)  "c := t
endfunction
1
  • 3
    This answer would benefit from an edit explaining what changes were made to the code and why.
    – D. Ben Knoble
    Aug 17 '21 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.