regex lookaround #9486
Replies: 10 comments 1 reply
-
I just tried the same thing —key for key— with Kakoune and it worked exactly as expected. |
Beta Was this translation helpful? Give feedback.
-
Just occurred to me that |
Beta Was this translation helpful? Give feedback.
-
A better way might be: As for why the lookahead doesn't work, it appears that the regex crate doesn't support look-around.
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@A-Walrus hm 🤔 seems I don't really understand the difference between select ( |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
As I understand it from the link above, the rust project has no intention of adding look arounds for their regex implementation. Does that mean this will always be the case for Helix? What is the general consensus on using a third party crate that supports more regex features? I find myself quite regularly piping out to the shell or using kak to make use of these features. If it's something the maintainers would consider, I'd love to have a crack at making a PR. |
Beta Was this translation helpful? Give feedback.
-
I don't really have strong opinions on this but I'm not convinced we need fancier regular expressions. In my experience you can convert most lookarounds to simpler regular expressions or sequences of |
Beta Was this translation helpful? Give feedback.
-
I know, I'm a little late to the party, but why not just include the fancy-regex crate? Why do this? |
Beta Was this translation helpful? Give feedback.
-
I'd like to also add that this is a feature I used all the time in vim, and I'd love for the same feature to exist in Helix. I understand rust probably wants the most performant implementation to be the default. In cases where you need negative lookaround you can simply postprocess matches using another regex pattern. However, in the case of a text editor, often a search is made over a single text file, in which case any performance hit from "fancy" regex would be negligible. Furthermore being able to achieve the same effect with a single command is almost always better than doing it with two or more. It would be nice if we could at the least provide a configuration option to enable the fancy-regex crate instead of the default. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I expected to be able to use a positive lookahead to split my selection, but it didn't seem to work.
I was looking to prepend every line that wasn't empty with a greater than sign followed by a space.
%
→S
→^(?=\S)
→ENTER
→i
→>
The regex worked as expected when I checked it here:
https://regex101.com/r/S99kPK/1
Beta Was this translation helpful? Give feedback.
All reactions