Hi im new to ack
(actually started half an hour ago). Im impressed by the quality of the search results.
But in my source files there are a lot of comments and if i search for a class/function-name i get about 20 results with commented lines and 2 with the actual code.
Is there a way to exclude text after //
and #
or between /* */
?
You could skip single line comments with something like this;
# ignore matches after //
ack '^[^//]*word'
# ignore matches after #
ack '^[^#]*word'
If you are using ag
instead, remember that it does multi-line matches:
# ignore matches after //
ag '^[^\n\r//]*word'
# ignore matches after #
ag '^[^\n\r#]*word'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With