mileszs / ack.vim

Vim plugin for the Perl module / CLI script 'ack'
Other
3.08k stars 396 forks source link

Can't search for text with "#" symbol in it #67

Closed johnkchow closed 10 years ago

johnkchow commented 11 years ago

I'm using HAML + JS, so I need to search for ids i.e. "#message". However, when the following search returns nothing in vim:

:Ack "#message" -Q --haml

I read all the options for the ack command so I think I'm using ack properly (I could be wrong). So is this me misunderstanding the '#' symbol in the context of vim, or is this issue from elsewhere?

johnkchow commented 11 years ago

I see what's going on here... my vim is expanding the '#' character into the current file name. I'll continue to investigate, sorry for the trouble :( Great job with the plugin!

johnkchow commented 11 years ago

So if I run :!ack "\#message", this correctly executes ack "#message" which returns the expected results. However, when I try to do :Ack "\#message", this returns no results.

blueyed commented 11 years ago

Try adding # to the escape call here:

silent execute a:cmd . " " . escape(l:grepargs, '|')

(plugin/ack.vim)

See also issue #14.

blueyed commented 10 years ago

The above hint won't work.

You will need to escape "#" and "%" in the argument to the command, but then also again for the shell (or quote it there). :Ack "\#message" turns into ack "NAME_OF_ALTERNATE_FILEmessage".