Sometimes I write something in brackets and then realize I've typed the wrong kind. For instance, in LaTeX:
\command(arguments)
Which should be:
\command{arguments}
I can jump between the two parentheses/braces using %
, but since %
doesn't work after the opening delimiter has been changed, in order to change both of the braces I have to do something like:
%r{f)r}
This doesn't seem like a big deal, but I find that switching from brace to parenthesis in the middle of the command sequence creates a surprising amount of cognitive dissonance, and this task often takes much longer than it feels like it ought to. Is there a plugin or simple hack that would provide an easier way? I would like it to be able to handle multiple pairs on the same line, so a simple substitution won't work, and I'd rather not define separate mappings for every pair of delimiters I'd like to convert between. (Just off the top of my head, '
, "
, ()
, {}
, and []
are all in the list I need to convert between, and I'd probably sooner or later find a use for <>
as well.)
A related problem is entirely removing a pair of brackets -- say I'm writing prose and have a sentence in parentheses and then decide it shouldn't be in them anymore. I can use da(
to get rid of the whole clause, or di(
to get rid of the content, but I want to get rid of the parentheses. The resulting command %xf)x
is much less annoying, but there's still some room for improvement.