Is there a way to enclose some text in parentheses (or curly brackets) in vim?
In other words, how would you do this?
Initial string:
It is sunny outside.
Final string:
It is (sunny) outside.
On a funny note, I just hit :w
to submit this question.
Happy vim-ing, SOCommunity!
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.
For one word, I've been using:
bcw()<Esc>P
That is, go to the start of the word, cut the word and go into insert mode, type the brackets and then exit insert mode and paste the word back in.
Keep in mind that this will overwrite your yank register.
You can, of course replace bcw with whatever movement and selection types you need, like
5cc{<Enter>}<Esc>P
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