Added support for tmux

This commit is contained in:
Renault John Lecoultre 2014-01-29 09:16:46 +01:00
parent 11f53fd930
commit 2523defcb6

View File

@ -1,17 +1,27 @@
" Code from: " Code from:
" http://stackoverflow.com/questions/5585129/pasting-code-into-terminal-window-into-vim-on-mac-os-x " http://stackoverflow.com/questions/5585129/pasting-code-into-terminal-window-into-vim-on-mac-os-x
" then https://coderwall.com/p/if9mda
" Docs on bracketed paste mode: " Docs on bracketed paste mode:
" http://www.xfree86.org/current/ctlseqs.html " http://www.xfree86.org/current/ctlseqs.html
if &term =~ "xterm.*" || &term =~ "screen*" if &term =~ "xterm.*" || &term =~ "screen*"
let &t_ti = &t_ti . "\e[?2004h" function! WrapForTmux(s)
let &t_te = "\e[?2004l" . &t_te if !exists('$TMUX')
function! XTermPasteBegin(ret) 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()
set pastetoggle=<Esc>[201~ set pastetoggle=<Esc>[201~
set paste set paste
return a:ret return ""
endfunction endfunction
map <expr> <Esc>[200~ XTermPasteBegin("i") inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()
imap <expr> <Esc>[200~ XTermPasteBegin("")
cmap <Esc>[200~ <nop>
cmap <Esc>[201~ <nop>
endif endif