Vim Tips Wiki

Using bar in external grep

Redirected from VimTip875

1,623pages on
this wiki
Add New Page
Add New Page Talk0
Tip 875 Printable Monobook Previous Next

created February 15, 2005 · complexity basic · author David S · version 5.7

It took me a while to notice this at :help :bar:

'|' can be used to separate commands, so you can give multiple commands in one line. If you want to use '|' in an argument, precede it with '\'.

When using bar in grep from a shell prompt you would use something like:

grep -i "main\(menu\|tool\)" *
grep -iE "main(menu|tool)" *

However, you must remember to add an extra escape to the '|' character in your regex when using grep from Vim, like so:

grep -i "main\(menu\\|tool\)" *
grep -iE "main(menu\|tool)" *


Also on Fandom

Random Wiki