• Login
Community
  • Login

Plugin or UDL to color whole lines by regexp?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 2 Posters 299 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.
  • Y
    Yuval Kfir
    last edited by Aug 31, 2022, 8:22 AM

    I’m looking for either a Notepad++ plugin, or a User-Defined Language, that will allow me to color lines in a file by regexp.
    E.g. a line containing “ERROR” (anywhere in the line) should be red, and a line containing “code [0-9]+” should be green (the whole line, not just the regexp).

    This appears quite simple (is it though?) yet I haven’t been able to locate any solution. “AnalysePlugin” comes close, but it doesn’t color the file itself but rather displays the lines in a separate window. I want the coloring to be like syntax highlighting.

    Does such a thing exist?
    Thanks in advance!

    P 1 Reply Last reply Aug 31, 2022, 1:13 PM Reply Quote 0
    • P
      PeterJones @Yuval Kfir
      last edited by PeterJones Aug 31, 2022, 1:13 PM Aug 31, 2022, 1:13 PM

      @Yuval-Kfir ,

      If by “color lines” you mean you want to change the foreground color, then you could probably use the EnhanceAnyLexer plugin:

      Assuming it’s a Normal text file, you would use Plugins > EnhanceAnyLexer > Enhance Current Language, and the plugin will add a section to its .ini file called [normal text] with an example pair of color (on the left of the equal) and regex (on the right of the equal).

      If you were to enter

      0x0000FF = ^.*ERROR.*$
      0xFF0000 = ^.*code [0-9]+.*$
      

      in the .ini file it opens, then when you switch to your text file, the text

      red
      blah
      Something ERROR something
      blah code 1234 here
      

      would look like
      d7c6d943-d3de-4d55-b295-d5712ef04527-image.png

      Y 1 Reply Last reply Aug 31, 2022, 1:47 PM Reply Quote 4
      • Y
        Yuval Kfir @PeterJones
        last edited by Aug 31, 2022, 1:47 PM

        @PeterJones Thank you! That is exactly what I needed.

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