I have the following text:
Monkeys eat {bananas}.
My cursor is in the middle of the word banana
:
Monkeys eat {bana|nas}.
Here the |
symbol denotes the cursor's position.
How can I delete the braces from there?
I can change bananas
to apples
with a simple ci}apples
, so perhaps I could use a similar trick just to get rid of the {
and }
characters?
Also, can I do this even in this case, which is actually what I really need to do?
networks {
local
is|p
}
(The simplified example above was just to introduce the concept.)
Now, your compiler (or lint) might tell you that the round brackets in Line 2 is redundant (in this case it is!) You wish to remove the brackets and you might use a combination of the d , x or w command in vim, or even go into INSERT mode and use backspace.
You can easily use the % key to jump to a matching opening or closing parenthesis, bracket or curly brace. You can also set the option showmatch . The cursor will briefly jump to the matching bracket, wen you insert one.
lh-brackets simply binds ( to surround the selection with the brackets. Unlike surround it doesn't follow the vim usual keybinding philosophy as does. Instead less keys are required.
Using Tim Pope's excellent surround.vim plugin (which I highly recommend), you would do ds{ for delete surrounding {
I understand that adding another plugin isn't always the ideal solution when you could find a native key sequence instead, but surround.vim is supremely useful, as it can also handle XML/HTML tags and perform enclosures on complex text objects. I regard it as one of those "stuck on a desert island, must have under any circumstance" plugins.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With