Wikia

Vim Tips Wiki

Using bar in external grep

Talk0
1,612pages on
this wiki
Revision as of 09:35, September 29, 2008 by JohnBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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\)" *
  or
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\)" *
  or
grep -iE "main(menu\|tool)" *

CommentsEdit

Around Wikia's network

Random Wiki