diff --git a/README.md b/README.md index c80af60..862c9b9 100644 --- a/README.md +++ b/README.md @@ -342,7 +342,7 @@ Multibyte Pairs input: h<|> press output: h| - pair: '\ws<': '>' (WRONG pair which missed \zs) + pair: '\w<': '>' (WRONG pair which missed \zs) input: h<|> press output: | (charactor 'h' is deleted) diff --git a/plugin/auto-pairs.vim b/plugin/auto-pairs.vim index 6509c31..a79dd4e 100644 --- a/plugin/auto-pairs.vim +++ b/plugin/auto-pairs.vim @@ -114,12 +114,12 @@ func! s:backspace(s) return repeat("\", s:ulen(a:s)) endf -func! s:getline() +func! s:getline(...) let line = getline('.') let pos = col('.') - 1 let before = strpart(line, 0, pos) let after = strpart(line, pos) - if g:AutoPairsMultilineClose + if a:0 == 0 && g:AutoPairsMultilineClose let n = line('$') let i = line('.')+1 while i <= n @@ -186,6 +186,9 @@ func! AutoPairsInsert(key) " check close pairs for [open, close] in b:AutoPairsList if a:key == g:AutoPairsWildClosedPair || close[0] == a:key + if open == close + let [before, after] = s:getline(0) + end let m = s:matchbegin(after, '\v\s*\zs\V'.close) if len(m) > 0 " skip close pair