2

I'm using vim Ag.vim from Silver Searcher. I would like to search let(:application in my project.

If I do :Ag "let(:application" app/ I get

|| ERR: Bad regex! pcre_compile() failed at position 16: missing )
|| If you meant to search for a literal string, run ag with -Q

No result with Ag -Q "let(:application" app/

Any idea of the right pattern ?

Andy Lester
  • 91,102
  • 13
  • 100
  • 152
Mio
  • 1,412
  • 2
  • 19
  • 41

2 Answers2

2

You can either escape the (:

Ag 'let\(:application' app/

Or use grep with -F for fixed strings:

grep -F "let(:application" app/
fedorqui
  • 275,237
  • 103
  • 548
  • 598
1

I guess you are confused by vim's magic pattern and ag's pattern:

The regex pattern parameter passed to ag does NOT follow your vim's magic setting. By default ag applies PCRE so you have to escape ( to let ag knows that you want to match literal (. Or you give -Q option to achieve the same goal.

Kent
  • 189,393
  • 32
  • 233
  • 301