diff --git a/plugin/delimitMate.vim b/plugin/delimitMate.vim index 9e47405..5b6509b 100644 --- a/plugin/delimitMate.vim +++ b/plugin/delimitMate.vim @@ -254,19 +254,19 @@ function! s:DelimitMateSwitch() "{{{ endif endfunction "}}} -function! s:Finish() +function! s:Finish() " {{{ if exists('g:delimitMate_loaded') return delimitMate#Finish(1) endif return '' -endfunction +endfunction " }}} -function! s:FlushBuffer() +function! s:FlushBuffer() " {{{ if exists('g:delimitMate_loaded') return delimitMate#FlushBuffer() endif return '' -endfunction +endfunction " }}} "}}} @@ -321,16 +321,34 @@ endfunction "}}} function! s:ExtraMappings() "{{{ " If pair is empty, delete both delimiters: inoremap delimitMateBS =delimitMate#BS() + if !hasmapto('delimitMateBS','i') + silent! imap delimitMateBS + endif " If pair is empty, delete closing delimiter: inoremap delimitMateS-BS delimitMate#WithinEmptyPair() ? "\=delimitMate#Del()\" : "\" + if !hasmapto('delimitMateS-BS','i') + silent! imap delimitMateS-BS + endif " Expand return if inside an empty pair: inoremap delimitMateCR =delimitMate#ExpandReturn() + if b:_l_delimitMate_expand_cr != 0 && !hasmapto('delimitMateCR', 'i') + silent! imap delimitMateCR + endif " Expand space if inside an empty pair: inoremap delimitMateSpace =delimitMate#ExpandSpace() - " Jump out ot any empty pair: + if b:_l_delimitMate_expand_space != 0 && !hasmapto('delimitMateSpace', 'i') + silent! imap delimitMateSpace + endif + " Jump over any delimiter: inoremap delimitMateS-Tab =delimitMate#JumpAny("\") + if b:_l_delimitMate_tab2exit && !hasmapto('delimitMateS-Tab', 'i') + silent! imap delimitMateS-Tab + endif " Change char buffer on Del: inoremap delimitMateDel =delimitMate#Del() + if !hasmapto('delimitMateDel', 'i') + silent! imap delimitMateDel + endif " Flush the char buffer on movement keystrokes or when leaving insert mode: for map in ['Esc', 'Left', 'Right', 'Home', 'End'] exec 'inoremap delimitMate'.map.' =Finish()<'.map.'>' @@ -355,27 +373,10 @@ function! s:ExtraMappings() "{{{ " Jump over next delimiters inoremap delimitMateJumpMany =len(b:_l_delimitMate_buffer) ? delimitMate#Finish(0) : delimitMate#JumpMany() - imap g delimitMateJumpMany + if !hasmapto('delimitMateJumpMany') + imap g delimitMateJumpMany + endif - " Map away! - if !hasmapto('delimitMateDel', 'i') - silent! imap delimitMateDel - endif - if !hasmapto('delimitMateBS','i') - silent! imap delimitMateBS - endif - if !hasmapto('delimitMateS-BS','i') - silent! imap delimitMateS-BS - endif - if b:_l_delimitMate_expand_cr != 0 && !hasmapto('delimitMateCR', 'i') - silent! imap delimitMateCR - endif - if b:_l_delimitMate_expand_space != 0 && !hasmapto('delimitMateSpace', 'i') - silent! imap delimitMateSpace - endif - if b:_l_delimitMate_tab2exit && !hasmapto('delimitMateS-Tab', 'i') - silent! imap delimitMateS-Tab - endif " The following simply creates an ambiguous mapping so vim fully processes " the escape sequence for terminal keys, see 'ttimeout' for a rough " explanation, this just forces it to work