Mercurial > addons > vim-scripts > vim-xsel-script
view plugin/xsel.vim @ 0:c293edf9fbac default tip
Initial revision
author | Guido Berhoerster <guido+vim@berhoerster.name> |
---|---|
date | Sat, 14 Mar 2015 10:57:21 +0100 |
parents | |
children |
line wrap: on
line source
" Vim xsel integration plugin " Maintainer: Guido Berhoerster <guido+vim@berhoerster.name> " Latest Revision: 2009-02-14 " License: " Copyright (c) 2009 <guido+vim@berhoerster.name> " " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the " "Software"), to deal in the Software without restriction, including " without limitation the rights to use, copy, modify, merge, publish, " distribute, sublicense, and/or sell copies of the Software, and to " permit persons to whom the Software is furnished to do so, subject to " the following conditions: " " The above copyright notice and this permission notice shall be included " in all copies or substantial portions of the Software. " " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, " EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. " IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY " CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, " TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. " Requirements: xsel (see http://www.vergenet.net/~conrad/software/xsel/) if exists("g:loaded_xsel") finish endif let g:loaded_xsel = 1 let s:save_cpo = &cpo set cpo&vim try if !hasmapto('<Plug>XselGetClipboard') map <unique> <Leader>gc <Plug>XselGetClipboard endif noremap <unique> <script> <silent> <Plug>XselGetClipboard :call <SID>GetClipboard('"')<CR> if !hasmapto('<Plug>XselSetClipboard') map <unique> <Leader>sc <Plug>XselSetClipboard endif noremap <unique> <script> <silent> <Plug>XselSetClipboard :call <SID>SetClipboard('"')<CR> if !exists(":GetClipboard") command -nargs=0 -register GetClipboard :call s:GetClipboard('<reg>') endif if !exists(":SetClipboard") command -nargs=0 -register SetClipboard :call s:SetClipboard('<reg>') endif function! s:GetClipboard(reg) let s:reg = a:reg if empty(s:reg) let s:reg='"' endif call setreg(s:reg, system("xsel -o -b")) if v:shell_error != 0 redraw! echohl ErrorMsg | echo "***error*** (GetClipboard) error executing xsel" | echohl None endif endfunction function! s:SetClipboard(reg) let s:reg = a:reg if empty(s:reg) let s:reg='"' endif call system("xsel -i -b", getreg(s:reg)) if v:shell_error != 0 redraw! echohl ErrorMsg | echo "***error*** (SetClipboard) error executing xsel" | echohl None endif endfunction finally let &cpo = s:save_cpo endtry