vim-bracketed-paste/plugin/bracketed-paste.vim

28 lines
771 B
VimL
Raw Normal View History

2013-04-07 16:56:00 -07:00
" Code from:
" http://stackoverflow.com/questions/5585129/pasting-code-into-terminal-window-into-vim-on-mac-os-x
2014-01-29 09:16:46 +01:00
" then https://coderwall.com/p/if9mda
2013-04-07 16:56:00 -07:00
" Docs on bracketed paste mode:
" http://www.xfree86.org/current/ctlseqs.html
2014-01-14 14:38:42 +00:00
if &term =~ "xterm.*" || &term =~ "screen*"
2014-01-29 09:16:46 +01:00
function! WrapForTmux(s)
if !exists('$TMUX')
return a:s
endif
let tmux_start = "\<Esc>Ptmux;"
let tmux_end = "\<Esc>\\"
return tmux_start . substitute(a:s, "\<Esc>", "\<Esc>\<Esc>", 'g') . tmux_end
endfunction
let &t_SI .= WrapForTmux("\<Esc>[?2004h")
let &t_EI .= WrapForTmux("\<Esc>[?2004l")
function! XTermPasteBegin()
2013-04-07 16:56:00 -07:00
set pastetoggle=<Esc>[201~
set paste
2014-01-29 09:16:46 +01:00
return ""
2013-04-07 16:56:00 -07:00
endfunction
2014-01-29 09:16:46 +01:00
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()
2013-04-07 16:56:00 -07:00
endif