3

This might rustle some feathers, but I do not like how vim's regular expression syntax differs from standard regex syntax (I've read this answer, but I don't think this is worth remember two syntaxes for).

Is there an option or a plugin to use standard (i.e., Perl) regex syntax instead of the vim specific one?

4
  • It is now that bad. It boils down to knowing where to put the `\` :)
    – eyal karni
    Sep 19, 2019 at 22:05
  • 1
    What do you consider standard regex syntax? If you mean Basic/POSIX, than Vis regex is already very close to it. So what exactly is your problem? Sep 20, 2019 at 6:11
  • @ChristianBrabandt I'm after PCRE syntax. Sep 20, 2019 at 18:04
  • Well, there is not much you can do. I have heard of people using something like nnoremap / /\v but that is still not fully PCRE compatible (besides there are regex atoms that simply do not exist in perl/prce). You can also try to use a perl-enabled build and always use perldo, that should come very close to PCRE. Sep 22, 2019 at 17:06

1 Answer 1

3

I haven't used it, so I can't vouch for how good it is. But after a bit of searching I found othree/eregex.vim (vim.org link), which is a plugin to enable Perl flavor regex.

This will not change the behavior of regex in vimscript, so if you want to use Perl flavor regex for things like highlighting groups, string comparisons, etc. you're out of luck.

But it will remap the behavior of / and ?, and allow you to do Perl flavor substitutions with :%S instead of :%s.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.