question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve highlighting of string formatting

See original GitHub issue

I’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: ruby javascript
  • Scope lists correctly, the same way as in fstrings: list
    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: type
    cats = 2
    print(f'She has {cats:02d} cats')
    print('She has %(cats)02d cats' % {'cats': cats})
    

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
timmeinhardtcommented, Nov 23, 2017

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!

1reaction
timmeinhardtcommented, Nov 23, 2017

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?

screen shot 2017-11-23 at 17 25 47
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found