Raimondi / delimitMate

Vim plugin, provides insert mode auto-completion for quotes, parens, brackets, etc.
http://www.vim.org/scripts/script.php?script_id=2754
1.98k stars 117 forks source link

Do not always delete empty pairs on <BS> #266

Open Emilgardis opened 6 years ago

Emilgardis commented 6 years ago

When chaining delimiters, e.g (foo(bar)), and then at (foo(bar)|) you press backspace to remove foo(bar)you end up with (|, but what you really wanted was (|).

This is sometimes a huge annoyance when having many delimiters and keeping track of how many open delimiters there are.

I propose a feature similar to balance_matchpair that keep track of opening pairs, and tries to only remove empty pairs when there is an even amount of pairs.

One problem with this is of course how to handle cases like the following rust code

let x: A<B<C>|> = foo(2 > 1);

here when we arrive at let x: A<B<|> = 2 > 1; we do have an even amount of delimiters, as such the correct behaviour would be to remove the empty pair, even if what we really wanted was to only remove the <. Now, we could make it so that we only check the left side, but I doubt that would fix anything. I'm not sure if this could be implemented (and I could always just use "_di) or "_di( but it'd sure be a nice addition.