Close empty pairs smartly
This commit is contained in:
parent
3413c38fe3
commit
f1d9a2bf63
@ -31,7 +31,7 @@ Features
|
||||
|
|
||||
} (press } to close the pair)
|
||||
output: {
|
||||
}| (the inserted empty line will be deleted)
|
||||
}| (the inserted blank line will be deleted)
|
||||
|
||||
|
||||
* Insert spaces before closing characters, only for [], (), {}
|
||||
|
@ -194,23 +194,28 @@ func! AutoPairsInsert(key)
|
||||
end
|
||||
if a:key == g:AutoPairsWildClosedPair || opt['mapclose'] && close[0] == a:key
|
||||
" the close pair is in the same line
|
||||
let m = matchstr(after, '^\v\s*\zs\V'.close)
|
||||
let m = matchstr(afterline, '^\v\s*\V'.close)
|
||||
if m != ''
|
||||
if b:autopairs_return_pos == line('.') && getline('.') =~ '\v^\s*$'
|
||||
normal! ddk$
|
||||
elseif col('.') > 1
|
||||
normal! h
|
||||
elseif line('.') > 1
|
||||
normal! k$
|
||||
if before =~ '\V'.open.'\v\s*$' && m[0] =~ '\v\s'
|
||||
" remove the space we inserted if the text in pairs is blank
|
||||
return "\<DEL>".s:right(m[1:])
|
||||
else
|
||||
return s:right(m)
|
||||
break
|
||||
end
|
||||
end
|
||||
let m = matchstr(after, '^\v\s*\zs\V'.close)
|
||||
if m != ''
|
||||
if a:key == g:AutoPairsWildClosedPair || opt['multiline']
|
||||
if b:autopairs_return_pos == line('.') && getline('.') =~ '\v^\s*$'
|
||||
normal! ddk$
|
||||
end
|
||||
call search(m, 'We')
|
||||
return "\<Right>"
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
endfor
|
||||
|
||||
" check open pairs
|
||||
|
Loading…
Reference in New Issue
Block a user