4

Note: this question is specific to the relatively new Ubuntu Bash on Windows system.

So it seems possible to paste into Vim from the Windows clipboard by simply right clicking in insert mode after enabling the Quick Edit Mode option.

But has anyone figured out how to paste into Windows something that was copied using Vim?

I've tried using the "* and "+ registers, but it seems as though they aren't even present. I ran :reg and only saw the "", "0, "., ":, "/ registers. Are other people at least seeing the registers? Or is it just me?

Also, my version of Vim has the +clipboard and +xterm_clipboard features installed.

What I can do is use the mouse, select text in vim, then right click to copy, then paste like normal in Windows. But I'd really rather just yank items in Vim into the Windows clipboard.

4

Thank you to @Christian Brabandt for linking this in the comments: https://www.reddit.com/r/vim/comments/7pmv3d/workflows_that_work/dskyram/

Works great. Just put the following in your vimrc and make sure to have vim version >= 8.0.1394

" WSL yank support
let s:clip = '/mnt/c/Windows/System32/clip.exe'  " default location
if executable(s:clip)
    augroup WSLYank
        autocmd!
        autocmd TextYankPost * call system('echo '.shellescape(join(v:event.regcontents, "\<CR>")).' | '.s:clip)
    augroup END
end

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.