You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
apparently it is a feature.
[...]
r is for RE, use R for raw string
AFAIK this is not a standard defined in any PEP, and popular code formatter such as black will convert any R'' strings into r'' by default.
I get the reasoning behind this decision, and there were some arguments for it since TextMate and Sublime Text both highlight Python syntax this way by default, but with the widespread use of VSCode these days (which does not highlight raw strings in Python this way by default) this argument seems outdated. Ideally this idiosyncratic highlighting could be made optional, preferably off by default.
Reacted by lyhyl, DetachHead, AuroraTea, Eduardo Roberto and corybon682
I struggled against this issue for a while coming from PyCharm to VSCode. Using some resources found online for editing TokenColorCustimizations and TextMateRules in the JSON settings, I was able to create a custom workaround at the link below. It's annoying having to manually enter hex codes for the colors to all match the way you'd expect inside of an r-string, but unless you are a person who changes themes often you should only have to make the edits once.
Activity
goldrik commentedon Sep 12, 2023
The issue was mentioned here back in 2020. The link contains some extra information that may be helpful.
The issue was closed there so that it could be reported somewhere more relevant instead, namely this repository.
DG119 commentedon Sep 21, 2023
apparently it is a feature.
Check this reply:
#114 (comment)
r is for RE, use R for raw string
gilbertohasnofb commentedon Jan 6, 2024
AFAIK this is not a standard defined in any PEP, and popular code formatter such as black will convert any
R''strings intor''by default.I get the reasoning behind this decision, and there were some arguments for it since TextMate and Sublime Text both highlight Python syntax this way by default, but with the widespread use of VSCode these days (which does not highlight raw strings in Python this way by default) this argument seems outdated. Ideally this idiosyncratic highlighting could be made optional, preferably off by default.
JelleZijlstra commentedon Apr 29, 2024
Black specifically does not change
R''tor''because of syntax highlighters treating the two differently. See https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#r-strings-and-r-strings.tylercowdreywadnr commentedon Jan 3, 2025
I struggled against this issue for a while coming from PyCharm to VSCode. Using some resources found online for editing TokenColorCustimizations and TextMateRules in the JSON settings, I was able to create a custom workaround at the link below. It's annoying having to manually enter hex codes for the colors to all match the way you'd expect inside of an r-string, but unless you are a person who changes themes often you should only have to make the edits once.
Instructions for adding the code to your VSCode user settings are contained in the .txt file here:
http://github.com/tylercowdreywadnr/VSCode_rstring_color_hack