Notepad++ UDL highlight line

1.2k Views Asked by At

I'm trying to define my own user defined language in notepad++. Reason: I want to introduce coloring schemes for different logfile entries. Does anbody know if there is a way to highlight the complete line containing a specific keyword?

2

There are 2 best solutions below

2
On BEST ANSWER

You could use comment line if the special keyword is at the beginning

comment line

If what you want is to know the lines with some errors, you better use the Mark tab of the search window with the check of Bookmark line.

Mark

[Edited 28 June 2016]

If you want a more powerful solution that fits your need exactly, you can try with the plugin Python Scripts.

Once the plugin installed, you can write a python script.

  • Create in your script a function highlight_preprocessor that does the following:
    1. For each keyword you have, remove any previous highlight by calling Editor.markerDeleteAll(<ID_keyword>) where <ID_keyword> is a digit associated to the keyword (e.g. 10 for error, 11 for warning, etc.)
    2. For each <ID_keyword>, set the colors of the highlight (e.g. dark gray) by calling the function editor.markerSetBack(<ID_keyword>, (<R>, <G>, <B>) ) (where the last 3 numbers are the RGB values of the color - 20/20/20 for dark grey)
    3. Parse the text of your document and for each line matching a keyword, call the function editor.markerAdd(<line_number>, <ID_keyword>)
  • Call the function each time the file is saved by putting this line at the end of your script notepad.callback(highlight_preprocessor, [NOTIFICATION.FILEBEFORESAVE])

Takes some time and effort to make it work but at least it is possible.

0
On

use ((EOL)) in close: so that it highlights till the end of the line with a specific keyword.