On 2020-10-11, @lbutlr <
kre...@kreme.com> wrote:
> On 11 Oct 2020, at 06:22, Bram Moolenaar <
Br...@moolenaar.net> wrote:
>> You can use any special character to surround the pattern, it's a lot
>> easier than escaping. I often use ":grep /pattern/ *", unless the
>> pattern contains a slash.
> As soon as I learned you could use any delimiter you wanted I stopped
> using / and switched to | as I never have to escape pipes.
You still need to escape # inside the pattern, don't you? As in:
:grep /\#foo/ *
At least, when 'grepprg' is grep (which is the default?). If it's set to
internal, then I can actually search for /#foo/.
Btw, as I was experimenting with grep commands, I have also realised
that a command with -complete=file expands #, but a command without it
does not. So, this is what I've come up with:
command! -nargs=+ Grep call s:grep(<q-args>)
fun s:grep(args)
execute 'silent grep!' shellescape(fnameescape(a:args)) '**/*'
endf
Then, s:grep() will receive '#foo' when I type :Grep #foo. Inside the
function, fnameescape() will escape # again for :grep!, and
shellescape() will escape the input for the shell. I have yet to test
this thoroughly, maybe there are better ways.
The drawback is that the custom command does not expand any path.
Life.
>> --
>> I'm trying to be an optimist, but I don't think it'll work.
>
> --
> No sense being pessimistic. It wouldn't work anyway.
>
> --
--
It's worse than that. It makes things fall apart.