I'd like to construct a mapping that would replace a b with c where the gap between a and b could be zero or more spaces or zero or more tabs, but not zero of both. There have been several related postings: This is the most promising of several postings, which addresses the problem in terms of regexp, but I can't get their syntax to work in vim. Thanks for any suggestions.

1 Answer 1


If you're looking for a substitute command:

:s/a[ \t]\+b/c/

The default regex mode doesn't see + as an operator. You have to escape it to make it special.

You can also use:


\s is Vim's shortcut for space and tabs in regex.


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.