Sublime Forum

Python new format string highlight

#1

Hello

The new way of formatting strings in Python (which is actually the recommended one since Python 2.6 came out in 2008) is through the format() method.

The old way, by position or by name:

'%s, %s' % ('Hello', 'World')

'%(greeting)s, %(recipient)s' % {'greeting':'Hello', 'recipient':'World'}

The new way, by position or by name:

'{0}, {1}'.format('Hello', 'World')

'{greeting}, {recipient}'.format(greeting='Hello', recipient='World')

It would appear to me that ST2 only highlights the old percert-style placeholders in strings, not the newer curly bracket ones (which by the way can contain all sorts of characters, not just letters and numbers, up to the closing curly bracket, as the new format system is extensible.)

Is there a setting to enable it? A plugin? Is it planned for a future upgrade?

0 Likes