wincent / ferret

🐀 Enhanced multi-file search for Vim
BSD 2-Clause "Simplified" License
692 stars 22 forks source link

Use `\v` by default in `:Acks` invocations triggered by the `<Plug>(FerretAcks)` mapping #61

Closed chiefjester closed 5 years ago

chiefjester commented 5 years ago

If I try to do :Ack foo|bar

then :Acks /foo|bar/baz/

It doesn't update anything?

wincent commented 5 years ago

You need a trailing slash. ie. :Acks /foo|bar/baz/

Surprised it didn't show an error.

wincent commented 5 years ago

Depending on your 'magic' Vim setting you may need to escape the | too (\|). Whatever you write gets passed through as-is to Vim as though you had written a :s command.

chiefjester commented 5 years ago

hey @wincent big fan here! Thanks for checking, but yeah, I just forgot to add a slash on the comment, but when I tried it it won't work.

chiefjester commented 5 years ago

@wincent I've added an asciinema recording: asciicast

chiefjester commented 5 years ago

sorry @wincent I didn't see your comment about magic setting

So my Acks should be like this? (need to add \v) ?

:Acks /\vfoo|bar/baz/

Also I was wondering, if Acks is using :cfdo under the hood, isn't "very magic" mode for vim is the most compatible with perl compatible and should be the default? That way it's a better partner for ag,ack,rg's regex since they more or less share the similar regex engine? Would you be open for a PR to make it default for <Leader>r?

I guess this is where we set that? https://github.com/wincent/ferret/blob/master/plugin/ferret.vim#L676-L677

wincent commented 5 years ago

Personally, I think "very magic" makes the most sense (Vim's idiosyncratic regular expressions drive me up the wall), but I am reluctant to ~tamper with~ manipulate people's defaults too much. I do that in the Loupe plugin, for example, but it is gated behind an option.

It's true that we could make the mapping prepend it by default, but I would probably want it to have an option for it.

chiefjester commented 5 years ago

I'm pro for making very magic default as well. I'm coming from from a vimgrep workflow where I can test my regex in search do a :cfdo s/<C-r>// after.

I wish vim plugins have semver, that way you can iterate over major versions and won't need to worry about breaking other people's workflow.

However, using very magic actually makes it closer to perl compatibility and would actually be an improvement rather than a regression.

But I do respect your reluctance. Perhaps some compromise of having a gated option as well? So that people can opt-in for the very magic? (If making it a default is a non option). We could also have a gate where users can use legacy bindings too?

wincent commented 5 years ago

I think it's probably ok to change the default even though people tend not to pay attention to semver, for a couple reasons:

wincent commented 5 years ago

I pushed a draft implementation of this to the "next" branch. I'll test it for a while there and if all looks good will merge that into "master".

chiefjester commented 5 years ago

sweet thanks for the update @wincent!