Open J-Fields opened 5 years ago
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. You should look into VIM implementations in javascript. There are a lot (not many good ones though).
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:
\< -> \b
\l -> [a-z]
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.
Hey guys, I imported a .vimrc which has nnoremap / /\v
and learned about the concept of 'very magic' in Vim which makes it so no regex characters need to be escaped in patterns. Is there any plans to add this in addition to magic / no magic? Vim also has \V
for 'very no magic' (who named these things?) as well as \m
and \M
for setting magic
and nomagic
on the fly.
Is there any plans to add this in addition to magic / no magic?
Yes, support for magic
is planned, though it may be a while before it's implemented
Is there any plans to add this in addition to magic / no magic?
Yes, support for
magic
is planned, though it may be a while before it's implemented
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: https://github.com/VSCodeVim/Vim/issues/7499#issuecomment-1039755795
s:(\S+):"\1":g
shows the replacement correctly in the UI, but then it provides E486: Pattern not found
when hitting enter.
%s/stroke=".*?"/stroke="currentColor"
also highlights the replacement correctly in the editor, but then it shows E486: Pattern not found: stroke=".*?"
when I try to replace.
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
(#4018)\%V
(#4936)\zs
and\ze
(#3073):help /branch
)