Improve highlighting of string formatting
See original GitHub issueI’d like to suggest the following changes which would improve string highlighting greatly imo:
- Scope brackets
{}
and%()
as punctuation. Many other language packages do this: - Scope lists correctly, the same way as in fstrings:
speed = [300] print('This car runs at {0[0]}km/h'.format(speed)) print(f'This car runs at {speed[0]}km/h')
- Scope format types in % strings, the same way as in fstrings:
cats = 2 print(f'She has {cats:02d} cats') print('She has %(cats)02d cats' % {'cats': cats})
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Python 3's f-Strings: An Improved String Formatting Syntax ...
As of Python 3.6, f-strings are a great new way to format strings. Not only are they more readable, more concise, and less...
Read more >Code analysis and helpers for string literals - ReSharper
Format method — interpolated strings. That's why ReSharper highlights usages of String.Format with the suggestion to convert them into ...
Read more >How to use String.Format - and why you should care about it
Even Microsoft itself recommends to use string interpolation because it is more readable (syntax highlighting helps you see better what are the ...
Read more >Highlighting pattern strings in a large text
Is there a better way to run this pattern matching, or a more efficient approach to find and highlight specific text? UPDATE: Sharing...
Read more >Highlight string formatting expressions and method operators ...
I am not sure what you are asking. ... I want PyCharm to highlight %(variable)s and {variable} in string literals, so they have...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank you for your fast response. I was indeed using two Python extensions (Python for VSCode and Python) simultaneously. This caused the inconsistencies. Sorry for the stupid mistake!
I am currently experiencing inconsistent
f-string
highlighting with Visual Studio Code. The issue of missing syntax highlighting occurs with more complex statements and if additional formatting info is present. Is this not yet implemented or a misconfiguration from my side?