1. Christian Ebert
  2. screenpaste

Wiki

Clone wiki

screenpaste / Home

Welcome to Screenpaste

screenpaste is a Vim plugin to paste the current GNU screen buffer.

Why Screenpaste?

The terminal window manager Screen offers the capability to copy and paste between windows. In principle you can just do C-a ] (default) to paste the current Screen buffer into a Vim buffer.

However this gives unexpected results when 'paste' is not set or in Vim's command-line. This script provides convenience mappings and functions to get correct results. As an additional feature the current Screen buffer is available in any Vim instance, even those outside the current screen session. Many commands are autodetected and the behaviour adapts automatically (see :help getcmdtype()).

Usage and Help

Screenpaste comes with extensive online help, available via

:help screenpaste

after installation.

Maps

Assuming the default mapleader \ and screenpaste's default mappings you can type:

modeaction
\pNormalput Screen buffer after cursor
\PNormalput Screen buffer before cursor
\gpNormalput Screen buffer after cursor and leave cursor after new text
\gPNormalput Screen buffer before cursor and leave cursor after new text
\pVisualreplace selection with Screen buffer
\gpVisualreplace selection with Screen buffer and leave cursor after new text
\pInsertinsert Screen buffer
\pReplaceinsert Screen buffer
\pCommand-lineinsert Screen buffer

Commands


:ScreenYank [x]

yanks Screen buffer [into register x]


:[line]ScreenPut [x]

puts Screen buffer after [line] (default: current line) using register [x]


:[line]ScreenPut! [x]

puts Screen buffer before [line] (default: current line) using register [x]


:ScreenCmdlineConf  search | sub | noesc

configure how to convert Screen buffer in Command-line mode

How to use :ScreenCmdlineConf

Set ScreenCmdlineConf depending on whether you want to use the Screen buffer in search or replace part of a substitution.

Examples as typed with default maps:

:ScreenCmdlineConf search
:s/\p/repl/
:ScreenCmdlineConf sub
:s/pattern/\p/

:ScreenCmdlineInfo

echoes info on current Command-line mode behaviour


:ScreenSearch

sets conversion of Screen buffer inserted in cmdline for search use


:ScreenSub

sets conversion of Screen buffer inserted in cmdline for substitution use


:ScreenNoEsc

sets end-of-line only conversion for Screen buffer insertion in cmdline


Vimrc Examples

" change mappings
" Normal and Visual mode
map  <Leader>P <Plug>ScreenpastePut
" Normal mode (put before cursor)
nmap <Leader>I <Plug>ScreenpastePutBefore
" Insert and Command-line mode
map! <F7> <Plug>ScreenpastePut

" change cmdline behaviour setting at startup
let g:screen_clmode = "sub"

" specify Screen executable (default: 'screen')
let g:screen_executable = "/usr/local/bin/screen"

" switch register used for Screen buffer (default: '"' for unnamed register)
let g:screen_register = "s"

" automatically select pasted text in Visual mode
let g:screen_visualselect = 1

" wait longer for Screen to finish writing its exchange file
let g:screen_wait = '500m'

Installation

Unzip screenpaste.zip into a $VIMRUNTIME directory.

Rebuild help tags by running :helptags ~/.vim/doc (assuming you installed into ~/.vim).

Updated