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

Replacement doesn't work as expected #186

Open
djsjo opened this issue Aug 21, 2024 · 5 comments · May be fixed by #190
Open

Replacement doesn't work as expected #186

djsjo opened this issue Aug 21, 2024 · 5 comments · May be fixed by #190

Comments

@djsjo
Copy link

djsjo commented Aug 21, 2024

Problem

I have some lines with times like:
11:30
11:45
12:00
12:15

and wanted to replace them with the same value + a colon and a space.

Used Command

:%s/\v(\d{2}:\d{2})/\1: /gc

Expected Results:

The accordings lines are replaced with the colon counterpart. Tested in "real" vim and it works.

Actual Results

Tested in codemirror.net
Getting the Information "No matches for \v(\d{2}:\d{2})" .

@nightwing
Copy link
Collaborator

We do not support \v modifier.
By default we use js compatible regexps so %s/(\d{2}:\d{2})/$1: /gc should work

Also it is possible to do :set nopcre :%s/\(\d{2}:\d{2}\)/\1: /gc

We need to implement better error messages/hints to show which mode of regular expressions is activated.

Do you think it would be useful to support \v in nopcre mode?

@nightwing nightwing linked a pull request Sep 16, 2024 that will close this issue
@nightwing
Copy link
Collaborator

@djsjo the attached pull request improves support for vim style regular expressions and informs user that regex mode can be changed. Could you try it on https://raw.githack.com/replit/codemirror-vim/verymagic/dev/web-demo.html and let us know if there are any issues. Thanks!

@djsjo
Copy link
Author

djsjo commented Sep 18, 2024

I will check it out in the middle of next week and report to you. Thanks

@djsjo
Copy link
Author

djsjo commented Sep 26, 2024

@nightwing everything works as anticipated and the feedback is very helpful. But when I set ":set nopcre" and then
":%s/(\d{2}:\d{2})/\1: /gc" it showed me "No matches for /(\d{2}:\d{2})/im"
I guess thats not the correct behaviour right?
The \v mode in nopcre mode worked fine :)

@nightwing
Copy link
Collaborator

In your example you did not escape the brace in {2}, and for me, the default configuration of vim, does not find matches for it either. \{2} works.
Does vim find matches without escaping the brace with your configuration?

Also how should + work, our old implementation does not require to escape it, but vim seems to require.

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

Successfully merging a pull request may close this issue.

2 participants