" Code from: " http://stackoverflow.com/questions/5585129/pasting-code-into-terminal-window-into-vim-on-mac-os-x " then https://coderwall.com/p/if9mda " and then https://github.com/aaronjensen/vimfiles/blob/59a7019b1f2d08c70c28a41ef4e2612470ea0549/plugin/terminaltweaks.vim " to fix the escape time problem with insert mode. " " Docs on bracketed paste mode: " http://www.xfree86.org/current/ctlseqs.html " Docs on mapping fast escape codes in vim " http://vim.wikia.com/wiki/Mapping_fast_keycodes_in_terminal_Vim if !exists("g:bracketed_paste_tmux_wrap") let g:bracketed_paste_tmux_wrap = 1 endif function! WrapForTmux(s) if !g:bracketed_paste_tmux_wrap || !exists('$TMUX') || system('tmux -V')[5] >= '2' return a:s endif let tmux_start = "\Ptmux;" let tmux_end = "\\\" return tmux_start . substitute(a:s, "\", "\\", 'g') . tmux_end endfunction let &t_ti .= WrapForTmux("\[?2004h") let &t_te .= WrapForTmux("\[?2004l") function! XTermPasteBegin(ret) set pastetoggle= set paste return a:ret endfunction execute "set =\[200~" execute "set =\[201~" map XTermPasteBegin("i") imap XTermPasteBegin("") vmap XTermPasteBegin("c") cmap cmap