Are there any vim plugins to enclose selected text in quotes or parentheses? For instance, if I were to select a block of text in visual mode, and pressed a key combination or do a command, that text would be enclosed in parentheses/quotes.

link|improve this question

feedback

2 Answers

up vote 2 down vote accepted

I use surround.vim for this type of thing. For example, visually select an area and type "\s(" and the visually selected text will be enclosed in parenthesis. Change the ( to a double quote and it will use quotes instead.

Unfortunately surround has some slightly odd behaviors, and the help file is sometimes a little unclear, but I find it tolerable.

link|improve this answer
Thanks! That was just what I needed! – Wuffers Dec 19 '10 at 3:13
feedback

I've been maintaining a plugin that offers this kind of feature: lh-map-tools. You'll have to tune it though to specify bracket-like pairs you want to support.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.