1

Using ACK in Vim, I want to find all instances of #pragma that does not end in once within C++ related files. What is the regex I need to use?

#pragma\s+.*(?<!once)$ works in Python and JavaScript, but I'm not sure how to get ACK to accept it.

:Ack --cpp #pragma\s+.*(?<!once)$ produces the following error in Vim:

E194: No alternate file name to substitute for '#'

Escaping the # with \\\ returns nothing. I have tried a few other modifications, but I'm not getting what I want.

Wandering Fool
  • 2,170
  • 3
  • 18
  • 48
Matthew Hoggan
  • 7,402
  • 16
  • 75
  • 140

1 Answers1

1

You need to escape # and the ! with a single backslash.

e.g.

:!ack-grep --cpp '\#pragma\s+.*(?<\!once)$'

I am unsure if :Ack runs the same in the background.

mathematical.coffee
  • 55,977
  • 11
  • 154
  • 194