I am writing a VimL function that, in insert mode, allows a <BS>
through the opening part of a pair ([
, {
, etc.) to delete the closing part of the pair if it is the next character after the cursor (much like auto-pairs and vim-autoclose). This function will be different because the closing part of the pair will not be deleted if there are unbalanced pairs.
Examples:
The format is <initial> => <result-after-backspace>
where my cursor is in front of the |
.
((|) => (|)
((|)) => (|)
(|) => |
(defn => (defn
(|) |)
How can I determine whether or not the pairs are unbalanced before I go ahead and delete the closing pair?
I have tested both auto-pairs and vim-autoclose. With both plugins the closing part of the pair is always deleted.