Mio
Mio

Reputation: 1502

Grep/Ack expression with parenthese and semicolon

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 ?

Upvotes: 2

Views: 316

Answers (2)

Kent
Kent

Reputation: 195029

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.

Upvotes: 1

fedorqui
fedorqui

Reputation: 289495

You can either escape the (:

Ag 'let\(:application' app/

Or use grep with -F for fixed strings:

grep -F "let(:application" app/

Upvotes: 2

Related Questions