3

I'm using the latest version of Notepad++ as of this post (version 7.3.3, 64-bit) with User Defined Language v.2.1.0.12.

I've added syntax highlighting for AutoHotkey provided by the AHK message board, but would like to customize a bit further.

Specifically, for any hotkey I'd like to highlight the entire line the same color, like so:

enter image description here

However, the only thing common to all hotkeys is that the line ends with ::.

I've done this example by setting ^ as the delimiter opening and :: as the delimiter closing, but this restricts me to only hotkeys that use the CTRL key. Spaces and alt codes such as line feed (ALT+010) appear to work in the Close delimiter field but not the Open (for obvious reasons).

enter image description here

Is this possible? Any clever ideas?

1

UDL seems somewhat restrictive since it's designed to be simple (no support for RegEx, limited support for custom characters, etc.).

If you have the AutoHotkey syntax loaded you can add the following as a delimiter. Depending on where else you have these characters though there will probably be text that gets highlighted inappropriately. You may be able to fix this with nesting of some sort. At a minimum it will let you play around with detecting multiple characters within the same delimiter rule.

Open:

^ || $ || ~ || ! || + || # || E || F

Close:

:: || :: || :: || :: || :: || :: || :: || :: 

It is also possible to lock the hotkey detection to the beginning of the line by using similar syntax for Comment highlighting (which has a checkbox for forcing it to start the beginning of the line), but then you can't use the regular comment syntax and there doesn't appear to be a way to cancel the comment highlighting (prior to EOL) if the Close character isn't detected.

This applies to the Delimiter rules also... so for example if # is listed in the Open rule and :: is listed in the close rule, a line with #IfWinActive Some Program will have a full highlight (vs. not being highlighted because the close characters weren't detected).

This may also be possible to fix with nesting or some special syntax but I couldn't figure out how to do that either.

|improve this answer|||||
  • This answer is basically saying "it's not possible". I appreciate that @jjohston2 investigated this with more depth that I would have known how to do. I gave him a +1 for listing partial solutions and saving me from wasting my time. – Ben Aug 2 '19 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.