From 4f2db7a48110f11bd582dc3471ec981620e37712 Mon Sep 17 00:00:00 2001 From: Israel Chauca Fuentes Date: Wed, 24 Mar 2010 02:55:06 -0500 Subject: [PATCH] Shift+Tab inside any empty pair will move the cursor out. --- plugin/delimitMate.vim | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/plugin/delimitMate.vim b/plugin/delimitMate.vim index db3769a..a0a0d1b 100644 --- a/plugin/delimitMate.vim +++ b/plugin/delimitMate.vim @@ -156,6 +156,15 @@ function! s:Init() "{{{1 let s:apostrophes = split(g:delimitMate_apostrophes) endif " }}} + if !exists("b:delimitMate_tab2exit") && !exists("g:delimitMate_tab2exit") " {{{ + let s:tab2exit = 1 + + elseif exists("b:delimitMate_tab2exit") + let s:tab2exit = split(b:delimitMate_tab2exit) + else + let s:tab2exit = split(g:delimitMate_tab2exit) + endif " }}} + let s:matchpairs = split(s:matchpairs_temp, ',') let s:left_delims = split(s:matchpairs_temp, ':.,\=') let s:right_delims = split(s:matchpairs_temp, ',\=.:') @@ -185,6 +194,23 @@ function! s:ValidMatchpairs(str) "{{{1 return 1 endfunction "}}}1 +function! DelimitMate_ShouldJump() "{{{1 + let char = getline('.')[col('.') - 1] + for pair in s:matchpairs + if char == split( pair, ':' )[1] + " Same character on the rigth, jump over it. + return 1 + endif + endfor + for quote in s:quotes + if char == quote + " Same character on the rigth, jump over it. + return 1 + endif + endfor + return 0 +endfunction "}}}1 + function! s:IsEmptyPair(str) "{{{1 for pair in s:matchpairs if a:str == join( split( pair, ':' ),'' ) @@ -384,6 +410,11 @@ function! s:ExtraMappings() "{{{1 if exists("b:delimitMate_expand_space") || exists("g:delimitMate_expand_space") inoremap =ExpandSpace() endif + + " Jump out ot any empty pair: + if s:tab2exit + inoremap DelimitMate_ShouldJump() ? "\" : "\" + endif endfunction "}}}1 function! s:TestMappings() "{{{1