How to highlight variables with % in Notepad++?

Scripting and setups with Notepad++ and AutoHotkey.
User avatar
BrockPlaysFortnite
Posts: 84
Joined: 06 Nov 2021, 08:47

How to highlight variables with % in Notepad++?

Post by BrockPlaysFortnite » 19 Jan 2022, 06:54

Hey guys I have mostly succeeded by now in completely copying my scite4ahk colors over to Notepad++ but the last thing I am missing is the percent sign highlighting.

Here is an example of how scite4ahk treats it:
Image

and here is Notepad++:
Image

First I tried changing the delimiter settings to this
Image

but this breaks all the code if I don't close the percent sign. It seems that Scite makes everything before any % sign blue no matter what but I have no idea what setting I have to change to achieve this 🧐

Philister
Posts: 33
Joined: 01 Apr 2016, 07:31

Re: How to highlight variables with % in Notepad++?

Post by Philister » 12 Apr 2022, 03:25

Found the solution here. Just make sure you remove % from the keyword and operator lists in case you have it in there.

Alternatively, if you want different styling options for both uses of %:
1. Define % as a keyword that requires a prefix - this covers your %var% cases.
2. Add % to the operator list in the edit box on the right side (for the operators that must be surrounded by whitespace) - in that way, e. g. in Loop, % expression, at least % is highlighted (with the operator colour), though there does not seem to be a way to highlight the expression as well.

HTH

Post Reply

Return to “Notepad++”