]> git.phdru.name Git - dotfiles.git/commitdiff
.vimrc: Restore `WrapForTmux`
authorOleg Broytman <phd@phdru.name>
Thu, 18 Jul 2019 23:00:10 +0000 (02:00 +0300)
committerOleg Broytman <phd@phdru.name>
Thu, 18 Jul 2019 23:00:10 +0000 (02:00 +0300)
.vimrc

diff --git a/.vimrc b/.vimrc
index 836b64623e3251782df63a9f3dec8bcc48eb1713..41d0e220f5ca14682d5a2dd2ba6607e788f70c9d 100644 (file)
--- a/.vimrc
+++ b/.vimrc
@@ -298,10 +298,22 @@ else
    cmap <f28> <nop>
    cmap <f29> <nop>
 
+   "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 = "\<Esc>Ptmux;"
+     let tmux_end = "\<Esc>\\"
+
+     return tmux_start . substitute(a:s, "\<Esc>", "\<Esc>\<Esc>", 'g') . tmux_end
+   endfunction
+
    " https://vim.fandom.com/wiki/Change_cursor_shape_in_different_modes
-   let &t_EI.="\e[2 q" "EI = NORMAL mode (ELSE)
-   let &t_SI.="\e[6 q" "SI = INSERT mode
-   let &t_SR.="\e[4 q" "SR = REPLACE mode
+   let &t_EI.=WrapForTmux("\e[2 q") "EI = NORMAL mode (ELSE)
+   let &t_SI.=WrapForTmux("\e[6 q") "SI = INSERT mode
+   let &t_SR.=WrapForTmux("\e[4 q") "SR = REPLACE mode
 
    "Cursor settings:
    "  1 -> blinking block