5 ms·
> - 'I want to surround this word in parentheses. <vaws(> (Visual-mode (region selection) Around Word Surround-with Matching-parens)' Holy shit, thank you. I'v
by fao_ 6y ago
> - 'I want to surround this word in parentheses. <vaws(> (Visual-mode (region selection) Around Word Surround-with Matching-parens)'
Holy shit, thank you. I've been looking for something like this for half a decade and never found it (I don't even know how I missed it!)
- Fellshard 6y agoI believe Vim-proper needs a plugin for that behaviour, so keep that in mind.
- fao_ 6y agoDo you know what plugin it is? I will try to search for an evil version (Or I could just write my own, but my task list is large and my energy very low these days)
- benjaminogles 6y agohttps://github.com/tpope/vim-surround https://github.com/tpope/vim-surround
- wraithy 6y agoThis is vim-surround by tpope[1]. It does way more than just basic brackets! [1]: https://github.com/tpope/vim-surround https://github.com/tpope/vim-surround
- artificialLimbs 6y agobcw()<Esc>P will do it without plugins.
- mellavora 6y agoysiwb yank-surround-in-word-brackets also does it. If you have https://github.com/tpope/vim-surround/ https://github.com/tpope/vim-surround/ installed.
- Fellshard 6y agoThanks for the translation! I'll keep that around for future reference.
- spectramax 6y agoCould you please explain why we use Yank here? From what I understand yank puts the surround-in-word in a register. But there is nothing surrounding the word! I thought yank was for copying and pasting stuff. I can't understand why ysiwb works :(
- gnubison 6y agoI believe that this is just an arbitrary choice that doesn't collide with other keys and is fairly consistent with the other keybindings — cs for changing delimiters, ds for deleting delimiters, and ys for creating delimiters.
- spectramax 6y agoThanks! That's really thorny. It goes against the grain of composability and logically destructuring the command into verbs and actions and modifiers. They should not overload y for yank. Choose anything else that's not used.