Skip to content

Instantly share code, notes, and snippets.

@jpommerening
Created September 26, 2013 10:53
Show Gist options
  • Save jpommerening/6712617 to your computer and use it in GitHub Desktop.
Save jpommerening/6712617 to your computer and use it in GitHub Desktop.
xclip from vim – I often find myself wanting to copy my vim selection to an X application. Vim has an optional feature for this (xterm_clipboard), but most installs come without the feature baked in. I could use the Shift-key when selecting, but that would copy my line numbers as well (and probably do other nasty things), so instead I wrote a li…
fun! Xclip() range
let l:_a = @a
exec a:firstline . ',' . a:lastline . 'yank a'
exec system('xclip', @a)
let @a = l:_a
endfun
" If you want to map this to Ctrl+c:
" vnoremap <C-c> :call Xclip()<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment