UDL might be one approach, but when I have a quick need for something like this, I record a Mark action to a macro and then tie that macro to a keycombination. Then when I need the highlighting, or to refresh it, I just hit the keycombo and the highlighting pops in.

@dinkumoil makes a good point about “bookmarks”, which will give you additional functionality.

If you add Mark line (tick the checkbox) into the Mark search you can quickly jump between your debug messages which would be very handy when your file is large. See Search (menu) -> Bookmark -> Next Bookmark (and of course also Previous Bookmark). [Technically you don’t need bookmarks to do this, as you can quickly move to redmarked text using Search (menu) -> Jump Down (or Up) -> Find Style.]

If you want to copy all of the lines touched by the redmarking, bookmarks help here: See Search (menu) -> Bookmark -> Copy Bookmarked Lines

So my thinking was the above (red)marking action might be recorded into a macro and tied to a keystroke, maybe ctrl+shift+e (whatever). Then when you want the highlighting, you press the keycombo. Then it occurred to me that it might also be desirable to remove the (red)marking with another keystroke, maybe ctrl+shift+alt+e (again, whatever).

However, when I did some experimenting, I found out that a press of the Clear button on the Mark tab of the Find window doesn’t get recorded into a macro.

Side note: This has been reported long ago as a Notepad++ issue, see “Case I”. Maybe it has also been discussed on the Community before as well…memory fails…

Worse yet than not being able to record it, you can’t hand-edit the file in which the macros are stored in order to make it work (this technique works in some other instances).

In short, you can’t clear (red)marking in any other way than bringing up the Mark window and pressing the Clear button. Or can you??

Well, if you’ll notice, the Mark window has an option for Purge for each search. Activating (ticking) this option means that when you run a new (red)marking operation, before Notepad++ runs it, it will erase all of the existing (red)marking. So if we just can find a Find what value which will never match anything, we should have a means to clear all existing (red)marking. I settled upon the following, wrapped into a complete solution:

Thanks to everyone for the answers. What I’m getting is that there are some hacks to sort of get close to what I want to do, but nothing that will get me automatic highlighting without running a macro every time I open the file, or the open file changes.

Well, if you’re going to be super-fussy about it… :-) …I’d probably say we aren’t out of good options with Notepad++ yet…maybe stay tuned…but I might say perhaps you aren’t using the right tool for the right job.

Everybody wants Notepad++ to be great at everything, but it’s really just great at its core duty: text editing. It isn’t great at searching…it isn’t great at log-file monitoring…it isn’t great at hex-editing…the list goes on and on.