Old text             Command         New text
Hello *world         ysiw(           Hello ( world )
Hello *world         ysiwb           Hello (world)
Hello *world          ysiw)           Hello (world)

Why does vim-surround add spaces to the first example, and is there a way to disable this?

Where the asterisk denotes cursor position

1 Answer 1


The plugin vim surround allows you to choose whether you want spaces and parenthesis or just parenthesis. You can disable it by using other mappings; actually you pasted them in your question, as the second and third examples.

This is actually a pattern in the mappings of this plugin: if you use the opening character - e.g.: (, { and [ - them it will include spaces. If you use the closing character - e.g.: ), } and ] - them it won't include spaces. The aliases for these blocks (b, B and r) also doesn't includes the spaces, probably because most of time the people (like you) doesn't want the spaces.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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