" File: screenpaste.vim " Description: pastes/inserts current GNU Screen buffer in (almost) any mode " Version: 5.92 " Mercurial: $Id: screenpaste.vim,v 41183f681647 2008-01-06 17:29 +0100 blacktrash $ " Author: Christian Ebert " Credits: Mathieu Clabaut and Guo-Peng Wen for inline doc self-install code " URL: http://www.vim.org/script.php?script_id=1512 " Requirements: GNU Screen must be in $PATH " Documentation: :help screenpaste " self installing to its current version when plugin is loaded " to review before install go to last section of this file " " GetLatestVimScripts: 1512 1 :AutoInstall: screenpaste.vim " Init: store 'compatible' settings {{{1 let s:save_cpo = &cpo set cpo&vim if !exists("g:loaded_screenpaste") " Fast Load: global vars, mappings, commands, doc install " load functions only on demand via autocmd " at Vim startup only run checks, load global vars, mappings, commands, " and install Help if not up to date or not present " full path to plugin -- needed for Screen_UpdateDocs and demand load let s:plug_path = expand(":p") " name of plugin w/o extension for messages let s:plug_name = fnamemodify(s:plug_path, ":t:r") " Global Variables: {{{1 " g:screen_executable: name of GNU Screen executable if !exists("g:screen_executable") let g:screen_executable = "screen" endif " g:screen_clmode: how screenpaste behaves in Vim's command-line if !exists("g:screen_clmode") let g:screen_clmode = "search" elseif g:screen_clmode !~# '^\%(s\%(earch\|ub\)\|noesc\)$' echomsg s:plug_name.": `".g:screen_clmode."':" \ "invalid value for screen_clmode." \ "Reset to 'search' (default)" let g:screen_clmode = "search" endif " g:screen_register: instead of register "0 use this one if !exists("g:screen_register") let g:screen_register = '"' elseif g:screen_register !~ '^["0-9a-zA-Z]$' echomsg s:plug_name.": `".g:screen_register."':" \ "invalid value for screen_register." \ "Reset to '\"' (default)" let g:screen_register = '"' endif if !exists("g:screen_visualselect") let g:screen_visualselect = 0 endif " Checks: for system() and Screen executable {{{1 function! s:Screen_CleanUp(msg) echohl WarningMsg echomsg s:plug_name.":" a:msg "Plugin not loaded" echohl None let g:loaded_screenpaste = "no" let &cpo = s:save_cpo unlet s:save_cpo s:plug_name g:screen_executable g:screen_clmode endfunction " bail out if system() is not available if !exists("*system") call Screen_CleanUp("builtin system() function not available.") finish endif " bail out if GNUscreen is not present if !executable(g:screen_executable) call Screen_CleanUp("`".g:screen_executable."' not executable.") finish endif let s:curr_version = "v5.92" " Mappings: propose defaults {{{1 if !hasmapto("ScreenpastePut") " nvo map p ScreenpastePut endif if !hasmapto("ScreenpasteGPut") " nvo map gp ScreenpasteGPut endif if !hasmapto("ScreenpastePutBefore", "n") nmap P ScreenpastePutBefore endif if !hasmapto("ScreenpasteGPutBefore", "n") nmap gP ScreenpasteGPutBefore endif if !hasmapto("ScreenpastePut", "ic") map! p ScreenpastePut endif " Internal Mappings: {{{1 nnoremap