Vim Tips Wiki

Using bar in external grep

Redirected from VimTip875

1,624pages on
this wiki
Add New Page
Talk0 Share
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)" *


Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki