Vim Surround inserts extra space around the word

VimSurround

Vim Problem Overview


When I select the word and use the surround plugin with S:

foobar

It becomes

( foobar )

How do I remove the extra spaces, so that it becomes

(foobar)

What should I place in my settings?

Vim Solutions


Solution 1 - Vim

If you type S(, it will be surrounded by spaces. However if you use the closing ) instead S) it will not be surrounded by spaces.

This applies of course to all bracket pair surroundings, <> [] {} (), not merely to (), although the behavior of S< is such that it expects a tag enclosure so only S> is able to surround as <>.

Solution 2 - Vim

When you use the surround plugin you can use:

cs) instead of cs( to surround without space :).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKitView Question on Stackoverflow
Solution 1 - VimMichael BerkowskiView Answer on Stackoverflow
Solution 2 - VimAhmed MasudView Answer on Stackoverflow