mileszs / ack.vim

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

Searches with "#" blow up #5

Closed jacquescrocker closed 12 years ago

jacquescrocker commented 14 years ago

I often need to search for strings that begin with "#" when finding id divs in haml/css

However Ack.vim explodes when using:

:Ack -Q "#something"

error:

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

ack -Q "#something" works fine from the command line so something in ack.vim is screwing it up

mileszs commented 14 years ago

Can you tell me your operating system, version of ack/ack-grep, etc.? I can't recreate your issue.

jacquescrocker commented 14 years ago

Sure, I'm using MacVim Snapshot 52 along with OSX 10.6.4. Ack version is 1.92 (perl 5.10). I'll try it with my Terminal vim instead, maybe its just a macvim bug

jacquescrocker commented 14 years ago

Same issue in pure terminal vim (version 7.2.108)

jacquescrocker commented 14 years ago

Here's all my config settings (http://github.com/railsjedi/vimconfig). Let me know if you can repro with this setup. Thanks!

blueyed commented 13 years ago

The issue at hand is that '#' will get replaced with the alternate file name. If you do not get E194 you'll have the alternative file name in that position instead.

You have to escape it like this :Ack '\\\#define foo' to search for #define foo.

I do not know if there is anything ack.vim could do about this to make it simpler (i.e. not require any escaping.

The same issue should apply to %, too.

butterywombat commented 12 years ago

thank you. i thought i was going crazy (searching exactly for # and % strings...gah)

ignovak commented 12 years ago

Have encountered this issue too. Escaping with '#' works, but I've spent some time to find it out:). Perhaps, it'd make sense to mention this point in the doc.

mileszs commented 12 years ago

Done.

Konfekt commented 10 years ago

@blueyed, why the triple slash to escape #, does one not suffice?

lkraav commented 10 years ago

I can confirm, triple is needed.

Konfekt commented 10 years ago

Ok. Is this under Linux? Still so if shellescape() is applied? I am wondering because # is not a special regex character.

weakish commented 9 years ago

Is this under Linux? Still so if shellescape() is applied? I am wondering because # is not a special regex character.

@Konfekt This is under all platforms. # is neither a special character in shell nor a special character in regex. As @blueyed pointed out, vim treats # specially. See :help expand for more information.

Konfekt commented 9 years ago

Ok, thank you. Now that I know about # as last buffer in the Vim command line it makes sense.

Sean-Lan commented 9 years ago

Hi, guys. I have just tried that with my MacVim (version 7.4.622), and it seems that only one back slash is enough and when I input three, nothing will be found.