Sublime Forum

Strange backslash highlighting

#1

MacBook Pro 15, macOS High Sierra 10.13.4

Update to 3.1 build 3170 and immediately noticed as that strange backslash highlighting appeared in Python code. Any ideas what to do? Thanks.

UPD: deleted settings posted earlier since according to the comments, they are not influencing the issue.

0 Likes

#2

That is “deprecated” highlighting. You are using backslash escapes incorrectly, but in a way that works due to historical reasons. Technically they should be written as '\\.'. https://bugs.python.org/issue27364.

0 Likes

#3

With Python, the convention for regular expression strings is to use a raw string. This actually enables regex highlighting in the string in Sublime Text:

my_regex = r'^.*\.jar'
0 Likes

#4

Well, thanks a lot for your quick and kind reply!

Strange, I am escaping the ‘.’ symbol, not the ‘’ symbol. Why would I use ‘\.’ here? Went to read the link…
I can change one-liners to r’…’, but I have multi-liner regex, which shines with all those nasty highlights now…
If I put r’ in front of every line, then some strange red-colored lines appear. What are those now?!
See second pic on my next comment (new users only allowed one pic in comment, lol :)))

It’s embarrassing since I’ve spent a lot of time to split it into multiple lines and also get it working then!
My perfectionism suffers…

0 Likes

#5

0 Likes

#6

That last screenshot definitely looks like a bug.

Now, it would be more logical to not split in the middle of a character range, but still that should not be marked as invalid.

0 Likes

#7

I am also getting this error, it has only come up since the update. Unknown why this is coming up espisily in a comment.

Thanks,
Adam

0 Likes