Wikia

Vim Tips Wiki

Using bar in external grep

Talk0
1,613pages on
this wiki
Revision as of 04:50, April 25, 2008 by JohnBot (Talk | contribs)

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)" *

Comments


Around Wikia's network

Random Wiki