From 3cca2bdb64b165e1661306c9cea8c4bf225030ea Mon Sep 17 00:00:00 2001 From: Vaarnan Drolia Date: Fri, 25 Apr 2014 01:15:58 +0800 Subject: [PATCH] Remove the escape delay when trying to exit insert mode using the escape key --- plugin/bracketed-paste.vim | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/plugin/bracketed-paste.vim b/plugin/bracketed-paste.vim index 18e7f61..38a891f 100644 --- a/plugin/bracketed-paste.vim +++ b/plugin/bracketed-paste.vim @@ -1,8 +1,12 @@ " 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 &term =~ "xterm.*" || &term =~ "screen*" function! WrapForTmux(s) if !exists('$TMUX') @@ -18,10 +22,17 @@ if &term =~ "xterm.*" || &term =~ "screen*" let &t_SI .= WrapForTmux("\[?2004h") let &t_EI .= WrapForTmux("\[?2004l") - function! XTermPasteBegin() + function! XTermPasteBegin(ret) set pastetoggle=[201~ set paste - return "" + return a:ret endfunction - inoremap [200~ XTermPasteBegin() + + execute "set =\[200~" + execute "set =\[201~" + map XTermPasteBegin("i") + imap XTermPasteBegin("") + vmap XTermPasteBegin("c") + cmap + cmap endif