Created
June 28, 2015 23:05
-
-
Save zuloo/ee3d4560c29af51224c6 to your computer and use it in GitHub Desktop.
Vim: copy to X clipboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" pipe range as a shellescaped string to the vimclip shell script | |
function Xclip() range | |
echo system('echo '.shellescape(join(getline(a:firstline, a:lastline), '\n')).'| ~/bin/vimclip') | |
endfunction | |
" bind Ctrl-c and Ctrl-Shift-c to copy | |
vmap <C-c> :call Xclip()<CR> | |
vmap <C-C> :call Xclip()<CR> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# export the DISPLAY, its not set when vim calls the script | |
export DISPLAY=:0.0 | |
# this line allows you to also copy the content of complete files to your | |
# X clipboard by calling this script with | |
# vimclip FILENAME | |
[ $# -ge 1 -a -f "$1" ] && input="$1" || input="-" | |
# this pipes the input/file to X default clipboard | |
cat $input | xclip -selection c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment