I'm trying to use
:grep to search for one of several words. Since grep accepts regular expressions, I figured I could just use the pipe character
| to build a single expression for both words:
:grep -E 'foo|baz' *.c
Vim interprets the
| as a separator between two commands.
:help :bar suggests that I could escape it as
\|, but that doesn't work, either. It seems that the
:grep command does not handle backspaces and quotes.
:help map-bar also offers the suggestion to use
^V|, which actually escapes the pipe character, but now the
^V is also in my pattern.
Right now, the only workaround I've found is using environment variables:
:let $BAR = '|' | grep -E 'foo'$BAR'baz' *.c
But this is quite crazy in my opinion. Is there really no better way?