Community
    • Login

    How to get correct syntax highlighting for Python 3 formatted strings

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    9 Posts 4 Posters 1.0k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J VickroyJ
      J Vickroy
      last edited by

      For me, Notepad++ 7.9.1 is rendering f-strings as unstyled text rather than in the style of regular strings.
      Could someone provide guidance on how to address this issue?
      Thanks.
      /jimv

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @J Vickroy
        last edited by

        @J-Vickroy

        Have you tried searching this forum for f-strings ?

        1 Reply Last reply Reply Quote 0
        • J VickroyJ
          J Vickroy
          last edited by

          Thanks for your quick response.

          I did search this forum prior to posting - implicit in my subject title being verbatim that of a previous (now locked) posting.
          My search revealed posts on this subject by you (among others) that seemed to indicate f-string styling should be supported by Notepad 3.9.1 without modification to XML configuration files. Am I mistaken?

          Prior to posting, I also verified C:\Program Files (x86)\Notepad++\stylers.model.xml contains F STRING specifications under the <LexerType name=“python” desc=“Python” ext=“”> tag.

          I’m misunderstanding something, but I do not know what.

          Michael VincentM PeterJonesP 2 Replies Last reply Reply Quote 0
          • Michael VincentM
            Michael Vincent @J Vickroy
            last edited by

            @J-Vickroy said in How to get correct syntax highlighting for Python 3 formatted strings:

            without modification to XML configuration files. Am I mistaken?

            You’re using the default styler, not a theme, correct?

            J VickroyJ 1 Reply Last reply Reply Quote 1
            • PeterJonesP
              PeterJones @J Vickroy
              last edited by

              @J-Vickroy said in How to get correct syntax highlighting for Python 3 formatted strings:

              Prior to posting, I also verified C:\Program Files (x86)\Notepad++\stylers.model.xml contains F STRING specifications under the <LexerType name=“python” desc=“Python” ext=“”> tag.

              Right. but does your %AppData%\Notepad++\stylers.xml (or, appropriate theme) also contain the F STRING. Because stylers.model.xml is only read if there isn’t a stylers.xml in an appropriate config directory (either the install directory or the appdata location I mentioned or in your cloud folder) – and that, only to effectively copy stylers.model.xml right\path\to\stylers.xml before loading that new stylers.xml. If you have an outdated stylers.xml (or if you have a different theme selected, and the theme config XML hasn’t been updated), then the config file Notepad++ actually reads that stylers.xml (or theme xml), and doesn’t see the F STRING setting.

              I did search this forum prior to posting - implicit in my subject title being verbatim that of a previous (now locked) posting.

              Hmm, I haven’t found that verbatim-title post yet. My search-fu must be weak.

              I did find Python Syntax Highlighting, whose last post gives the strong indication that having an outdated theme can be the culprit.

              Or then there’s the Python 3 f-strings not colourizing correctly discussion, where the user supplied the screenshot showing that the Style Configurator was out of date – where I even provide a procedure for how to copy the relevant portions of stylers.model.xml into stylers.xml, if you don’t want to overwrite any other customizations you’ve made to stylers.xml.

              J VickroyJ 1 Reply Last reply Reply Quote 1
              • J VickroyJ
                J Vickroy @Michael Vincent
                last edited by

                @Michael-Vincent
                Thanks for your reply. I was using the Zenburn theme, but switching to Default (stylers.xml) did not alter the behavior.

                PeterJonesP 1 Reply Last reply Reply Quote 0
                • PeterJonesP
                  PeterJones @J Vickroy
                  last edited by

                  @J-Vickroy said in How to get correct syntax highlighting for Python 3 formatted strings:

                  switching to Default (stylers.xml) did not alter the behavior.

                  … which confirms that your stylers.xml has not been updated to match stylers.model.xml. (and I just checked: the most recent zenburn.xml has not been updated to have f-string syntax…)

                  So follow the instructions I linked which explain how to get those appropriate lines from stylers.model.xml into stylers.xml or zenburn.xml, or whatever theme you want to put them in (same instructions, different filename).

                  J VickroyJ 1 Reply Last reply Reply Quote 1
                  • J VickroyJ
                    J Vickroy @PeterJones
                    last edited by

                    @PeterJones
                    Thanks Peter.

                    I just verified my %AppData%\Notepad++\stylers.xml file did not contain any F * entries.
                    Adding the F * entries to stylers.xml and switching to the Default theme fixed the issue. So it seems, I did have to modify an XML (stylers.xml) file.

                    All that remains is for me to determine how to make it work for other (e.g., Zenburn) themes.

                    1 Reply Last reply Reply Quote 2
                    • J VickroyJ
                      J Vickroy @PeterJones
                      last edited by

                      @PeterJones
                      Thanks again Peter for your followup post with the link on how to repair for non-default themes! This is great and I learned something in the process!

                      1 Reply Last reply Reply Quote 2
                      • First post
                        Last post
                      The Community of users of the Notepad++ text editor.
                      Powered by NodeBB | Contributors