4 ms·
If I want to put parens around a word I do, ciw()<ESC>P (change word pulls it into the default register, insert the parens and then paste from the register back
by aidos 11y ago
If I want to put parens around a word I do, ciw()<ESC>P (change word pulls it into the default register, insert the parens and then paste from the register back between the parens).
You can use the same pattern for any selection you have visually highlighted, such is the wonderful power of vim.
- sillysaurus3 11y agoHandy trick. Thanks!
- thomasahle 11y agoNice use of the buffer. Is there a nice hack to remove the parentheses around a word as well?
- aidos 11y agoI guess you could do a similar thing: ci(<backspace><delete><esc>p
- ksmithbaylor 11y agoca( would work for this as well.
- saltycraig 11y agoIf you have the cursor just before the area you could do: 'dt)' meaning delete to next ), or 'ct)' to delete until next ) and the drop into insert mode. Learning word objects in Vim for me is one of the killer features, and one thing I miss in Emacs.
- mkehrt 11y agoTake a look at vim-surround, which adds mappings for a lot of things like this.