From: Oleg Broytman Date: Fri, 14 Apr 2017 07:05:55 +0000 (+0300) Subject: .vimrc: automatically set paste mode when pasting in bracketed paste mode X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=e3cb095585b84b3bc5c10472ec9d82e9b904bfef;p=dotfiles.git .vimrc: automatically set paste mode when pasting in bracketed paste mode --- diff --git a/.vimrc b/.vimrc index e0b3298..4b7fdf8 100644 --- a/.vimrc +++ b/.vimrc @@ -262,6 +262,30 @@ else let &t_fs = "\007" endif endif + + " Automatically set paste mode in Vim when pasting in bracketed paste mode + " https://coderwall.com/p/if9mda/automatically-set-paste-mode-in-vim-when-pasting-in-insert-mode + 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 "" + endfunction + + inoremap [200~ XTermPasteBegin() endif " Multiline comments often confuse vim syntax highlighting - these maps