Modifying existing language settings
I would like to add some custom tags in Notepad++'s HTML syntax highlighting, so that both the tag and it’s attributes are colored accordingly.
Is it possible to copy and modify OR import and edit the HTML language file from somewhere or do I have to do everything by hand (custom + official HTML tags) in the User-Defined Language window?
The HTML syntax highlighter doesn’t have any user-defined keyword slots in the Style Configurator > HTML settings. Unfortunately, that means you can’t add them to the builtin lexer.
So you could use UDL (though it won’t have all the features of the HTML lexer), or you can add extra highlighting to a builtin lexer using regexes via the script
EnhanceAnyLexer.pythat @Ekopalypse shares in his github repo
That’s a bummer. Oh well, thank you for your answer!
Actually, I just thought of and confirmed an alternative.
langs.xmlconfig file (so probably in
%AppData%\Notepad++\langs.xmlif you have a normal installation) does list the standard tags that the HTML parser recognizes. If you follow best practices for editing config files, you can add a tag to the list, save, and then re-start Notepad++. For example, here’s a screenshot after I told Notepad++ that
<aardvark>was a valid HTML tag, but not
<aardvark>and its attributes are colored just like normal tags, but
<anteater>is still in default color because it’s not a recognized tag name.
@PeterJones This worked just the way I wanted. Thanks!