Delete duplicated pairs in one time.
eg ```|``` {{|}} [[|]]
This commit is contained in:
parent
f11f3e5ee3
commit
c0593a61c7
@ -142,7 +142,7 @@ function! AutoPairsInsert(key)
|
||||
let pprev_char = line[col('.')-3]
|
||||
if pprev_char == open && prev_char == open
|
||||
" Double pair found
|
||||
return a:key."\<CR>".repeat(a:key,3)."\<Up>\<ESC>o"
|
||||
return repeat(a:key, 4) . repeat("\<LEFT>", 3)
|
||||
end
|
||||
end
|
||||
|
||||
@ -170,12 +170,35 @@ function! AutoPairsDelete()
|
||||
return "\<BS>\<DEL>"
|
||||
endif
|
||||
|
||||
" Delete Repeated Pair eg: '''|''' [[|]] {{|}}
|
||||
if has_key(b:AutoPairs, prev_char)
|
||||
let times = 0
|
||||
let p = -1
|
||||
while get(prev_chars, p, '') == prev_char
|
||||
let p = p - 1
|
||||
let times = times + 1
|
||||
endwhile
|
||||
|
||||
let close = b:AutoPairs[prev_char]
|
||||
let left = repeat(prev_char, times)
|
||||
let right = repeat(close, times)
|
||||
|
||||
let before = strpart(line, pos-times, times)
|
||||
let after = strpart(line, pos, times)
|
||||
if left == before && right == after
|
||||
return repeat("\<BS>\<DEL>", times)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if has_key(b:AutoPairs, prev_char)
|
||||
let close = b:AutoPairs[prev_char]
|
||||
if match(line,'^\s*'.close, col('.')-1) != -1
|
||||
" Delete (|___)
|
||||
let space = matchstr(line, '^\s*', col('.')-1)
|
||||
return "\<BS>". repeat("\<DEL>", len(space)+1)
|
||||
elseif match(line, '^\s*$', col('.')-1) != -1
|
||||
" Delete (|__\n___)
|
||||
let nline = getline(line('.')+1)
|
||||
if nline =~ '^\s*'.close
|
||||
let space = matchstr(nline, '^\s*')
|
||||
|
Loading…
x
Reference in New Issue
Block a user