Skip to content

Instantly share code, notes, and snippets.

@naddeoa
Created May 17, 2020 21:07
Show Gist options
  • Save naddeoa/c09c513d50efd8327ea484f994ed3d39 to your computer and use it in GitHub Desktop.
Save naddeoa/c09c513d50efd8327ea484f994ed3d39 to your computer and use it in GitHub Desktop.
Copy from vim into system clipboard on windows subsystem for linux
" Kind of hacky but it works. This just copies stuff to a file to cat it into the windows clipboard and then
" deletes the file so that you don't have anything risky laying around in there.
" fake copy current line or selection
noremap YY "yyy \| :call writefile( getreg('y', 1, 1), $HOME.'/.vimbuffer') \| :!cat $HOME/.vimbuffer \| clip.exe <CR> \| :!rm $HOME/.vimbuffer<CR>
" fake copy entire file
noremap <C-a> :%y y \| :call writefile( getreg('y', 1, 1), $HOME.'/.vimbuffer') \| :!cat $HOME/.vimbuffer \| clip.exe <CR> \| :!rm $HOME/.vimbuffer<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment