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
Support Vim's flavor of regex #3996
Comments
Very interested in this. The whole point of using the VIM extension is so I don't have to learn yet another editor and its quickiness. |
If this ever gets integrated, I believe it would be a good to have the option. I've been heavily using a variety of regex engines for more years than I care to say and I always thought Vim's regex syntax was clunky. |
I think there is another option with less effort than a full regex engine. I am stealing ;-) this idea from vsvim. What the guys there did, is a "tokenwise" translation. Meaning:
And so on... A lot of vim regex could be translated like so and you can also do a lot with simple "left to right" translation, meaning no full parsing. Limits are where functionality is principally missing in js regex. |
Yeah that's a good point, @sql-koala, I've pondered it before. There are definitely limitations, but it'd be a good first solution I think. |
Central to this refactor is a rationalization of pattern parsing - we now have an immutable`Pattern` class with its own Parsimmon parser; it's now used everywhere. A few enhancements, such as supporting `/{pattern}/` as line specifier in line range And some bugs fixed: - `\n` now expands to `\r?\n` (to work with CRLF files) - `\<` and `\>` (word boundaries) are now mapped to `\b` Refs #3996
Hey guys, I imported a .vimrc which has |
Yes, support for |
I can try to work on this if you want. I don't know if there's more pressing issues you would rather have contributors for. |
Just noting here that with the new (fantastic!) inccommand addition, this issue makes it all the more puzzling when it seems like the RegEx matches, the UI updates, but it doesn't actually do anything because the RegEx doesn't match when doing the replace (from what I can tell). See this comment: #7499 (comment) |
|
|
We currently use javascript's regex library, which is unfamiliar to some coming from vim (see #2043, #3073, #3075, etc.). This ticket is to consolidate those and center discussion around the possibility of supporting Vim's regex flavor.
As a first step, I've created the
Pattern
class with its own parser - this essentially just translates a Vim-style regex into a JS-style regex.Current status:
\<
/\>
=>\b
(technically, this is not quite right)\n
on Windows (allow leading\r
)\1
, etc.):help /character-classes
)magic
(/ searching uses magic regex by default #4018)\%V
(\%V
not recognized in substitutions within visual selections. #4936)\zs
and\ze
(Make\zs
and\ze
work in Vim search to only include substring of match #3073):help /branch
)The text was updated successfully, but these errors were encountered: