addons/vim-scripts/vim-xsel-script

changeset 0:c293edf9fbac tip

Initial revision
author Guido Berhoerster <guido+vim@berhoerster.name>
date Sat Mar 14 10:57:21 2015 +0100 (2015-03-14)
parents
children
files README doc/tags doc/xsel.txt plugin/xsel.vim
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/README	Sat Mar 14 10:57:21 2015 +0100
     1.3 @@ -0,0 +1,53 @@
     1.4 +Vim xsel Script
     1.5 +===============
     1.6 +
     1.7 +The xsel script for Vim integrates vim with the [xsel utility][1] in order to
     1.8 +copy text from and to X CLIPBOARD selection.
     1.9 +
    1.10 +[1]: http://www.vergenet.net/~conrad/software/xsel/ "xsel"
    1.11 +
    1.12 +Usage
    1.13 +-----
    1.14 +
    1.15 +See the included documentation in Vim help format.
    1.16 +
    1.17 +Contact
    1.18 +-------
    1.19 +
    1.20 +Please send any feedback, translations or bug reports via email to
    1.21 +<guido+weechat@berhoerster.name>.
    1.22 +
    1.23 +Bug Reports
    1.24 +-----------
    1.25 +
    1.26 +When sending bug reports, please always mention the exact version of the script
    1.27 +with which the issue occurs as well as the version of vim and the operating
    1.28 +system you are using and make sure that you provide sufficient information to
    1.29 +reproduce the issue and include any input, output, and any error messages.
    1.30 +
    1.31 +License
    1.32 +-------
    1.33 +
    1.34 +Except otherwise noted, all files are Copyright (C) 2009 Guido Berhoerster and
    1.35 +distributed under the following license terms:
    1.36 +
    1.37 +Copyright (C) 2009 Guido Berhoerster <guido+vim@berhoerster.name>
    1.38 +
    1.39 +Permission is hereby granted, free of charge, to any person obtaining
    1.40 +a copy of this software and associated documentation files (the
    1.41 +"Software"), to deal in the Software without restriction, including
    1.42 +without limitation the rights to use, copy, modify, merge, publish,
    1.43 +distribute, sublicense, and/or sell copies of the Software, and to
    1.44 +permit persons to whom the Software is furnished to do so, subject to
    1.45 +the following conditions:
    1.46 +
    1.47 +The above copyright notice and this permission notice shall be included
    1.48 +in all copies or substantial portions of the Software.
    1.49 +
    1.50 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    1.51 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    1.52 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    1.53 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    1.54 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    1.55 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    1.56 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/doc/tags	Sat Mar 14 10:57:21 2015 +0100
     2.3 @@ -0,0 +1,10 @@
     2.4 +:GetClipboard	xsel.txt	/*:GetClipboard*
     2.5 +:SetClipboard	xsel.txt	/*:SetClipboard*
     2.6 +<Leader>gc	xsel.txt	/*<Leader>gc*
     2.7 +<Leader>sc	xsel.txt	/*<Leader>sc*
     2.8 +<Plug>XselGetClipboard	xsel.txt	/*<Plug>XselGetClipboard*
     2.9 +<Plug>XselSetClipboard	xsel.txt	/*<Plug>XselSetClipboard*
    2.10 +xsel	xsel.txt	/*xsel*
    2.11 +xsel-commands	xsel.txt	/*xsel-commands*
    2.12 +xsel-mappings	xsel.txt	/*xsel-mappings*
    2.13 +xsel.txt	xsel.txt	/*xsel.txt*
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/doc/xsel.txt	Sat Mar 14 10:57:21 2015 +0100
     3.3 @@ -0,0 +1,39 @@
     3.4 +*xsel.txt*			xsel script	       Last change: 2009-02-19
     3.5 +
     3.6 +xsel integration for Vim				*xsel*
     3.7 +
     3.8 +1. Mappings		|xsel-mappings|
     3.9 +2. Commands		|xsel-commands|
    3.10 +
    3.11 +The xsel script for Vim integrates vim with the xsel utility in order to copy
    3.12 +text from and to X CLIPBOARD selection. It requires xsel to be installed (see
    3.13 +http://www.vergenet.net/~conrad/software/xsel/).
    3.14 +
    3.15 +==============================================================================
    3.16 +1. Mappings						*xsel-mappings*
    3.17 +
    3.18 +					*<Leader>sc* *<Plug>XselSetClipboard*
    3.19 +<Leader>sc
    3.20 +<Plug>XselSetClipboard
    3.21 +				Set the X CLIPBOARD to the content of the
    3.22 +				unnamed register.
    3.23 +
    3.24 +					*<Leader>gc* *<Plug>XselGetClipboard*
    3.25 +<Leader>gc
    3.26 +<Plug>XselGetClipboard
    3.27 +				Get the content of the X CLIPBOARD selection
    3.28 +				and store it in the unnamed register.
    3.29 +
    3.30 +==============================================================================
    3.31 +2. Commands						*xsel-commands*
    3.32 +
    3.33 +							*:SetClipboard*
    3.34 +:SetClipboard {reg}		Set the X CLIPBOARD to the content of the
    3.35 +				register {reg}.
    3.36 +
    3.37 +							*:GetClipboard*
    3.38 +:GetClipboard {reg}		Get the content of the X CLIPBOARD and store
    3.39 +				it in the register {reg}.
    3.40 +
    3.41 +==============================================================================
    3.42 +  vim:tw=78:ts=8:ft=help:norl:
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/plugin/xsel.vim	Sat Mar 14 10:57:21 2015 +0100
     4.3 @@ -0,0 +1,79 @@
     4.4 +" Vim xsel integration plugin
     4.5 +" Maintainer:       Guido Berhoerster <guido+vim@berhoerster.name>
     4.6 +" Latest Revision:  2009-02-14
     4.7 +" License:
     4.8 +"   Copyright (c) 2009 <guido+vim@berhoerster.name>
     4.9 +"
    4.10 +"   Permission is hereby granted, free of charge, to any person obtaining
    4.11 +"   a copy of this software and associated documentation files (the
    4.12 +"   "Software"), to deal in the Software without restriction, including
    4.13 +"   without limitation the rights to use, copy, modify, merge, publish,
    4.14 +"   distribute, sublicense, and/or sell copies of the Software, and to
    4.15 +"   permit persons to whom the Software is furnished to do so, subject to
    4.16 +"   the following conditions:
    4.17 +"
    4.18 +"   The above copyright notice and this permission notice shall be included
    4.19 +"   in all copies or substantial portions of the Software.
    4.20 +"
    4.21 +"   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    4.22 +"   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    4.23 +"   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    4.24 +"   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    4.25 +"   CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    4.26 +"   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    4.27 +"   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    4.28 +" Requirements: xsel (see http://www.vergenet.net/~conrad/software/xsel/)
    4.29 +
    4.30 +if exists("g:loaded_xsel")
    4.31 +  finish
    4.32 +endif
    4.33 +let g:loaded_xsel = 1
    4.34 +
    4.35 +let s:save_cpo = &cpo
    4.36 +set cpo&vim
    4.37 +
    4.38 +try
    4.39 +    if !hasmapto('<Plug>XselGetClipboard')
    4.40 +        map <unique> <Leader>gc <Plug>XselGetClipboard
    4.41 +    endif
    4.42 +    noremap <unique> <script> <silent> <Plug>XselGetClipboard :call <SID>GetClipboard('"')<CR>
    4.43 +
    4.44 +    if !hasmapto('<Plug>XselSetClipboard')
    4.45 +        map <unique> <Leader>sc <Plug>XselSetClipboard
    4.46 +    endif
    4.47 +    noremap <unique> <script> <silent> <Plug>XselSetClipboard :call <SID>SetClipboard('"')<CR>
    4.48 +
    4.49 +    if !exists(":GetClipboard")
    4.50 +        command -nargs=0 -register GetClipboard :call s:GetClipboard('<reg>')
    4.51 +    endif
    4.52 +
    4.53 +    if !exists(":SetClipboard")
    4.54 +        command -nargs=0 -register SetClipboard :call s:SetClipboard('<reg>')
    4.55 +    endif
    4.56 +
    4.57 +    function! s:GetClipboard(reg)
    4.58 +        let s:reg = a:reg
    4.59 +        if empty(s:reg)
    4.60 +            let s:reg='"'
    4.61 +        endif
    4.62 +        call setreg(s:reg, system("xsel -o -b"))
    4.63 +        if v:shell_error != 0
    4.64 +            redraw!
    4.65 +            echohl ErrorMsg | echo "***error*** (GetClipboard) error executing xsel" | echohl None
    4.66 +        endif
    4.67 +    endfunction
    4.68 +
    4.69 +    function! s:SetClipboard(reg)
    4.70 +        let s:reg = a:reg
    4.71 +        if empty(s:reg)
    4.72 +            let s:reg='"'
    4.73 +        endif
    4.74 +        call system("xsel -i -b", getreg(s:reg))
    4.75 +        if v:shell_error != 0
    4.76 +            redraw!
    4.77 +            echohl ErrorMsg | echo "***error*** (SetClipboard) error executing xsel" | echohl None
    4.78 +        endif
    4.79 +    endfunction
    4.80 +finally
    4.81 +    let &cpo = s:save_cpo
    4.82 +endtry