2013-04-07 19:56:00 -04:00
|
|
|
" Code from:
|
|
|
|
" http://stackoverflow.com/questions/5585129/pasting-code-into-terminal-window-into-vim-on-mac-os-x
|
2014-01-29 03:16:46 -05:00
|
|
|
" then https://coderwall.com/p/if9mda
|
2014-04-24 13:15:58 -04:00
|
|
|
" and then https://github.com/aaronjensen/vimfiles/blob/59a7019b1f2d08c70c28a41ef4e2612470ea0549/plugin/terminaltweaks.vim
|
|
|
|
" to fix the escape time problem with insert mode.
|
2014-04-26 15:08:24 -04:00
|
|
|
"
|
2013-04-07 19:56:00 -04:00
|
|
|
" Docs on bracketed paste mode:
|
|
|
|
" http://www.xfree86.org/current/ctlseqs.html
|
2014-04-24 13:15:58 -04:00
|
|
|
" Docs on mapping fast escape codes in vim
|
|
|
|
" http://vim.wikia.com/wiki/Mapping_fast_keycodes_in_terminal_Vim
|
2015-01-01 22:37:00 -05:00
|
|
|
|
|
|
|
if !exists("g:bracketed_paste_tmux_wrap")
|
|
|
|
let g:bracketed_paste_tmux_wrap = 1
|
|
|
|
endif
|
|
|
|
|
2014-09-24 14:22:50 -04:00
|
|
|
function! WrapForTmux(s)
|
2015-01-01 22:37:00 -05:00
|
|
|
if !g:bracketed_paste_tmux_wrap || !exists('$TMUX')
|
2014-09-24 14:22:50 -04:00
|
|
|
return a:s
|
|
|
|
endif
|
2014-01-29 03:16:46 -05:00
|
|
|
|
2014-09-24 14:22:50 -04:00
|
|
|
let tmux_start = "\<Esc>Ptmux;"
|
|
|
|
let tmux_end = "\<Esc>\\"
|
2014-01-29 03:16:46 -05:00
|
|
|
|
2014-09-24 14:22:50 -04:00
|
|
|
return tmux_start . substitute(a:s, "\<Esc>", "\<Esc>\<Esc>", 'g') . tmux_end
|
|
|
|
endfunction
|
2014-01-29 03:16:46 -05:00
|
|
|
|
2014-09-24 14:22:50 -04:00
|
|
|
let &t_SI .= WrapForTmux("\<Esc>[?2004h")
|
|
|
|
let &t_EI .= WrapForTmux("\<Esc>[?2004l")
|
2014-01-29 03:16:46 -05:00
|
|
|
|
2014-09-24 14:22:50 -04:00
|
|
|
function! XTermPasteBegin(ret)
|
|
|
|
set pastetoggle=<f29>
|
|
|
|
set paste
|
|
|
|
return a:ret
|
|
|
|
endfunction
|
2014-04-24 13:15:58 -04:00
|
|
|
|
2014-09-24 14:22:50 -04:00
|
|
|
execute "set <f28>=\<Esc>[200~"
|
|
|
|
execute "set <f29>=\<Esc>[201~"
|
|
|
|
map <expr> <f28> XTermPasteBegin("i")
|
|
|
|
imap <expr> <f28> XTermPasteBegin("")
|
|
|
|
vmap <expr> <f28> XTermPasteBegin("c")
|
|
|
|
cmap <f28> <nop>
|
|
|
|
cmap <f29> <nop>
|