diff --git a/plugin/AutoPair.vim b/plugin/AutoPair.vim index ccbb317..2faa7e5 100644 --- a/plugin/AutoPair.vim +++ b/plugin/AutoPair.vim @@ -13,6 +13,9 @@ inoremap { {}U inoremap ) :call AutoPair#Close(')') inoremap ] :call AutoPair#Close(']') inoremap } :call AutoPair#Close('}') +inoremap " :call AutoPair#Quote('"') +inoremap ' :call AutoPair#Quote("'") +inoremap ` :call AutoPair#Quote('`') "}}} " New line between brace pair {{{ @@ -20,6 +23,13 @@ inoremap } :call AutoPair#Close('}') inoremap :call AutoPair#InsertBlankLine(@.) "}}} +fun! AutoPair#Quote(mapChar) + let l:nextChar = strpart(getline('.'), col('.') - 1, 1) + let l:prevChar = strpart(getline('.'), col('.') - 2, 1) + let l:feedkeys = (l:nextChar ==# a:mapChar || l:prevChar ==# a:mapChar) ? a:mapChar : a:mapChar . a:mapChar . "\" + call feedkeys(l:feedkeys, 'n') +endf + function! AutoPair#Close(mapChar) "{{{ let l:nextChar = strpart(getline('.'), col('.') - 1, 1)