ENH: Better highlightling for raw strings
has2k1 opened this issue · 2 comments
Github's highlighting of raw strings makes regexes more readable. For example:
var = '^[a-zA-Z0-9]+([^\s\w\d])*\W{3,4}\[\]|(?:abc.+)\1$' # not highlighted
var = r'^[a-zA-Z0-9]+([^\s\w\d])*\W{3,4}\[\]|(?:abc.+)\1$' # highlightedThe above regex may not give the full picture, but we make some sense
of the highlighting. You have four colours for:
- dark-blue: regular text
abc, and grouping chars(), (?: ) - light-blue: anchors characters
^, $, and character classes[a-zA-Z0-9], [\s\w\d], \W, . - red: quantifiers
*, +, ?, {3,4},, and special characters|, ^ - green: escapes including back-references
\[\], \1
IMO glancing at the code should immediately make it clear where strings are located. Doing something like you propose will make that much harder.
I have since thought about this and I think the best place for it is in a custom after/syntax/python.vim. There isn't a nice way to do it that would make it portable across different themes. Plus there may be performance implications as vim warns about using look-around regexes, and they would be indispensable for this task.
I will implement this for myself and put the code up somewhere.