Enclose text in Parentheses (and Other Characters) in VIM WITHOUT PLUGINS05 Jan 2023 11:30 UTC-08:00
Whether I'm creating a backlink or adding a url or a comment I often need to wrap text in parenteses or other characters. I've been a VIM (or VIM mode) user for a while and I never committed how to do this to memory. Let's change that.
How to do it
# In VISUAL Mode with the text selected c()<Esc>P
For those not in the VIM world
c - changes the text and puts the previous text in the buffer (think clipboard)
() - creates brackets. You can replace with braces, brackert or single/double quotes. You can also add as many of these as you wish.
That sounds like a lot
It kinda is (especially if VIM isn't your thing) which is why if you do this a lot you are better off mapping those steps in your config file to a command.
vnoremap <C-(> c()<esc>P
Most of the commands are the same. The
vnoremap ensures that this only runs in VISUAL Mode (When you select text) and
<C-(> is the command for