mileszs / ack.vim

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

escape special chars in `<cword>` when run `:Ack<CR>` #234

Open FuDesign2008 opened 6 years ago

FuDesign2008 commented 6 years ago

In javascript / php, $ is valid in a variable.

function $sayHello () {}

If we run :Ack<CR> when cursor is under $sayHello, nothing will be found.

So try to escape $ and wrap <cword> in ' .

benknoble commented 5 years ago

I wonder if shellescape or fnameescape might help?

FuDesign2008 commented 5 years ago
  1. This commit is only fix for the word that includes $, is not a universal solution.
  2. The source file has following comment. I'm not familiar with vimscript and can't find a better solution.
    
    " NOTE: we escape special chars, but not everything using shellescape to
    "       allow for passing arguments etc