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

1 Answer 1

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
2
  • 3
    This answer would benefit from an edit explaining what changes were made to the code and why.
    – D. Ben Knoble
    Aug 17, 2021 at 18:33
  • @charleskong, Maybe could you accept your answer. It allows the question to rest. Jul 12, 2023 at 6:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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