Community
    • Login

    # colors lines comments when they should not be

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 3 Posters 128 Views 1 Watching
    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.
    • Steve ValliereS Offline
      Steve Valliere
      last edited by

      Basic Info: Running on Windows 11, fully up-to-date as of this post. Using Notepad v8.9.8.1 (64-bit)

      I am sure this is somehow my fault and I am hoping folks will take pity on me and help… (hopeful smile)

      When I edit INI files, lines that begin with EITHER a semicolon ‘;’ OR a hash mark (AKA pound symbol, ‘#’) are colored as comments. HOWEVER, the Windows INI processing functions DO NOT consider a ‘#’ symbol as a comment marker.

      I have not touched the langs.xml file that was installed with Notepad++ and when I looked at it, I didn’t see anything that indicated it should consider the ‘#’ to begin a comment line.

      I have also created my own language definition for a custom config file type that I use. My files also use an initial semicolon as a comment marker and also do not use an initial ‘#’ as a comment marker. HOWEVER, Notepad++'s syntax coloring disagrees and colors lines starting with a ‘#’ as comments anyway.

      Is this a bug in Notepad++'s syntax coloring system, or is there some way that I defined ‘#’ as a comment indicator in both INI and my custom files without ever actually referencing that particular character in the files (except as an operator in my custom language definition)?

      How can I correct this annoying behavior? Since I also maintain config files on some linux servers, I often mix up the comment characters and Notepad++'s incorrect coloring is causing it to take longer than it should for me to notice my mistakes.

      Thanks! I hope…

      Lycan ThropeL 1 Reply Last reply Reply Quote 0
      • Lycan ThropeL Offline
        Lycan Thrope @Steve Valliere
        last edited by Lycan Thrope

        @Steve-Valliere ,
        Best suggestion I can give you is to look at the EnhanceAnyLexer plugin, and create a change of coloring to match what a # is colored in the Windows INI prossing functions, that would give you the comfort of knowing they aren’t comment indicators and prevent your files, while being edited in NPP, from seeing a # as a comment marker.

        Enable that plugin through the manager, read up on the instructions, and it should take care of what you need, using stock NPP ini file language recognition.

        Good luck.

        1 Reply Last reply Reply Quote 0
        • D Offline
          DanielCollins
          last edited by

          You are right about Windows INI files, and this is not something you did wrong in langs.xml.

          For INI files, Notepad++ uses the built in INI lexer, and that lexer treats both ; and # at the start of a line as a comment. That behavior is in the lexer itself, not in langs.xml, which is why you did not find # listed as a comment marker there. Windows itself only treats ; as a comment in INI files, so the coloring is misleading for your files, but it is expected Notepad++ behavior, not a mistake in your setup.

          For your own language definition, check two things separately. First, open Language, Define your language, select your language, then look at the Comment and Delimiter tab and make sure # is not listed as a comment line opener. Second, check that the file is actually using your language, not INI: the Language menu should show your language name when that file is active, and the file extension should be assigned to your language only. Listing # as an operator should not turn a line into a comment on its own, so if # lines are still colored as comments in your custom files, the INI lexer is the likely cause, because the file is being treated as INI.

          Lycan Thrope’s EnhanceAnyLexer suggestion is a good workaround for the INI case, because it lets you override the comment color for # lines so they look like normal text. For your custom language, removing # from any comment definition in the UDL, then saving and reopening the file, is the cleaner fix. If you test with a small file that only has one # line and one ; line, you can tell at once which lexer is coloring it.

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors