vim

Delete surrounding whitespace in vim


I'm using the awesome https://github.com/tpope/vim-surround plugin to surround words with parenthesis, for example I often use: viws<space><space> to surround a word with spaces.

What I'm missing is the opposite of this, that is, deleting surrounding spaces around a word.

The most common use for me is function arguments like foo(bar) vs foo( bar ) depending on code style.

Does anyone know a nice way to do this?


Solution

  • Note: This solution requires the surround plugin referenced in the question.

    For your specific situation you could do the following:

    cs()
    

    This changes foo( bar ) to foo(bar), however, it is not a general solution to your problem.