From e3cb095585b84b3bc5c10472ec9d82e9b904bfef Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 14 Apr 2017 10:05:55 +0300 Subject: [PATCH] .vimrc: automatically set paste mode when pasting in bracketed paste mode --- .vimrc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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 -- 2.39.5