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
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/a\s\+b/c/
\s
is Vim's shortcut for space and tabs in regex.