Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
chiefjester opened this issue Jun 1, 2019 · 10 comments

Comments

@chiefjester
Copy link

chiefjester commented Jun 1, 2019

If I try to do
:Ack foo|bar

then
:Acks /foo|bar/baz/

It doesn't update anything?

@wincent
Copy link
Owner

wincent commented Jun 1, 2019

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

Surprised it didn't show an error.

@wincent
Copy link
Owner

wincent commented Jun 1, 2019

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
Copy link
Author

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
Copy link
Author

@wincent I've added an asciinema recording:
asciicast

@chiefjester
Copy link
Author

chiefjester commented Jun 1, 2019

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
Copy link
Owner

wincent commented Jun 1, 2019

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
Copy link
Author

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?

@chiefjester chiefjester changed the title regex or doesn't work regex pipe doesn't work Jun 2, 2019
@wincent
Copy link
Owner

wincent commented Jun 2, 2019

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

  • We will have an escape hatch (an option).
  • The behavior change will be obvious (because when you hit the mapping, you'll see :Acks /\v...// instead of :Acks /...//).

@wincent
Copy link
Owner

wincent commented Jun 2, 2019

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".

@wincent wincent changed the title regex pipe doesn't work Use \v by default in :Acks invocations triggered by the <Plug>(FerretAcks) mapping Jun 2, 2019
@chiefjester
Copy link
Author

sweet thanks for the update @wincent!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants