diff --git a/plugin/bracketed-paste.vim b/plugin/bracketed-paste.vim index 25959c2..18e7f61 100644 --- a/plugin/bracketed-paste.vim +++ b/plugin/bracketed-paste.vim @@ -1,17 +1,27 @@ " Code from: " 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: " http://www.xfree86.org/current/ctlseqs.html if &term =~ "xterm.*" || &term =~ "screen*" - let &t_ti = &t_ti . "\e[?2004h" - let &t_te = "\e[?2004l" . &t_te - function! XTermPasteBegin(ret) + function! WrapForTmux(s) + if !exists('$TMUX') + return a:s + endif + + let tmux_start = "\Ptmux;" + let tmux_end = "\\\" + + return tmux_start . substitute(a:s, "\", "\\", 'g') . tmux_end + endfunction + + let &t_SI .= WrapForTmux("\[?2004h") + let &t_EI .= WrapForTmux("\[?2004l") + + function! XTermPasteBegin() set pastetoggle=[201~ set paste - return a:ret + return "" endfunction - map [200~ XTermPasteBegin("i") - imap [200~ XTermPasteBegin("") - cmap [200~ - cmap [201~ + inoremap [200~ XTermPasteBegin() endif