Kakoune: [Suggestion] '.' matching newline character

Created on 18 Dec 2016  路  6Comments  路  Source: mawww/kakoune

Hi,

With the defaults of boost::regex, . matches the newline character. More often that not, I'm only interested in covering the current line when I type .*, so I have to use [^\n]* to work around it which is a bit annoying.

Would it be possible to expose the boost setting match_not_dot_newline, maybe as an option for interactive use?

Most helpful comment

Sure, but I think it's a bit too annoying to type that instead of just .. Like I said, most of the time I just want to match on the same line.

edit: also there's the fact that this default is not consistent across regex implementations. re2, and I think pcre by default do not have . matching newline. I'm of the opinion that this would be a better default in kakoune too.

All 6 comments

I think something like (?-s) allows you to force . to only match non newlines in the regex

You're right, it does. I can't find any reference to this in the boost documentation, are there other flags that can change the behaviour mid-regex?

smix are the Perl modifiers mentioned in the boostregex documentation.

Thanks, I've found them documented here. m and i should be the most useful for interactive use, and they can be toggled on/off mid-regex with (?_) and (?-_).

I guess for my issue I can just make mappings that prepend this prefix to all regex entered, although that's not super elegant.

Using [^\n]* is an acceptable way too, there are a few scattered in the builtin scripts.

Sure, but I think it's a bit too annoying to type that instead of just .. Like I said, most of the time I just want to match on the same line.

edit: also there's the fact that this default is not consistent across regex implementations. re2, and I think pcre by default do not have . matching newline. I'm of the opinion that this would be a better default in kakoune too.

Was this page helpful?
0 / 5 - 0 ratings