2

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?

  • It is now that bad. It boils down to knowing where to put the `\` :) – eyal karni Sep 19 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? – Christian Brabandt Sep 20 at 6:11
  • @ChristianBrabandt I'm after PCRE syntax. – jlicht Sep 20 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. – Christian Brabandt Sep 22 at 17:06
2

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, privacy policy and cookie policy

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