First of all I noticed such things: the built-in syntax has a fixed set of keywords,
they are all in one big group and I cannot define different styles for separate keywords.

E.g. print, True, False, etc, should have different color, but how can I setup them separately?
Is it true it is impossible to do with built-in Python lexer? If so, any plans to improve that?

So I have googled that and found that “User defined language” method.
Well, I was stubborn enough and made it all through, but frankly speaking it could have
been made a bit easier.
My thoughts about it - there should be definitely one panel with a palette editor where I can
pick and edit colors directly for all style groups. It could simplify the whole process 100 times :-)

Ok, with UDL I am able to colorize keywords now. Cool, I was able to get a nice setup picture finally…
BUT - I cannot use folding now no matter what I try it is not working. :-o
Is it possible to define Python foldings with UDL? I found older questions
on this and the answer is that it is not possible. This is really sad.
Also I cannot find how to highlight def function name.

Actually I see vertical grey lines (indent marks) in Python correctly, so NPP already has
the information about indent? is it planned to include Python folding in the library?
I think the algorithm behind it is very simple - like detect indent change,
when next line indent is bigger, then include in fold, otherwise stop fold.

Now I am in such intersting situation: I have two options: built-in can folding and function/class names
but cannot keyword groups. And UDL can keywords but cannot folding and names. :-/
I personally like customizing but still folds are useful especially for 'def’s and long if-blocks.

builtin lexer
There are several piece which need to work together.
First you need to checkout if the builtin lexer supports multiple keyword sets.
In LexPython.cxx we see, that the python lexer supports two sets.
To create another set of keywords which then can be recognized by npp you
need to modify the langs.xml file. I.e. add another Keywords tag,
name it instre2 and provide the list of words (in sorted order).
Next you need to modify your used style file, which is either stylers.xml,
if the default theme is used, or one of the theme files. What you need to do
is to add another WordsStyle tag, name it like you want, assign the nextstyleID number and, most important, add the keywordClass tag with value instre2.
Restart npp.

user defined language (udl)
Afaik the only way to make this work is to cheat,
meaning e.g. you have to use unique comments as closing folding identifiers.

Not named but another solution might be to use python script plugin.
You get all that you need to write your own lexer.
It might be not as fast as the builtin ones but you get the possibility to add additional features.

builtin lexer
There are several piece which need to work together.
First you need to checkout if the builtin lexer supports multiple keyword sets.
In LexPython.cxx we see, that the python lexer supports two sets.
To create another set of keywords which then can be recognized by npp you
need to modify the langs.xml file. I.e. add another Keywords tag,
name it instre2 and provide the list of words (in sorted order).
Next you need to modify your used style file, which is either stylers.xml,
if the default theme is used, or one of the theme files. What you need to do
is to add another WordsStyle tag, name it like you want, assign the nextstyleID number and, most important, add the keywordClass tag with value instre2.
Restart npp.

I did this but it does not really work. More precisely, it works only partially - after I make changes to “langs.xml”
and stylers.xml there appears a new styler group under Python language, but the keywords in “instre2” list appeared in black color.
If I change the new styler color it does not affect the look of keywords.
However I have accidentally discovered that they are colored with the color from
“Global styles” -> “default style”
And one additional group is not enough anyway. I need some 4 groups at least to optimize the look.

user defined language (udl)
Afaik the only way to make this work is to cheat,
meaning e.g. you have to use unique comments as closing folding identifiers.

Yes that works. Now I am thinking that having custom tags for folding is in some sense better
solution, because I can adjust the chunks I want to fold manually.

Not named but another solution might be to use python script plugin.
You get all that you need to write your own lexer.
It might be not as fast as the builtin ones but you get the possibility to add additional features.

had to smile because I’ve asked myself the same question as I first discovered this.
doublequoted strings are string style and singlequoted strings are character style.
But still not sure where this comes from.

doublequoted strings are string style and singlequoted strings are character style.
But still not sure where this comes from

I may be offbase here because I’m not really following the conversation, but what this reminds me of is C/C++ where doublequoted runs of characters are null-terminated “strings” and single-quoted single elements are “characters”.