SVG syntax highlighting
I have noticed that if I selefct HTML language, I get only HTML and Java syntax highlighting, without SVG tags.
The lexers that ship with Notepad++ were determined by an old version of the Scintilla editor component that’s embedded in Notepad++; any feature requests for those default lexers would have to go through Scintilla’s feature-request (after first verifying that Scintilla didn’t already make those updates). Then, after it’s implemented, you would have to ask the Notepad++ developer to upgrade the Scintilla in Notepad++: since the last time Notepad++ updated it’s Scintilla was from 3.34 to 3.56 in June 2015, and Scintilla is currently on 4.1.3, the chances of a Scintilla-upgrade in Notepad++ are unfortunately slim at this point.
Alternatively, there is a User Defined Language (UDL) lexer, which would allow you to define some of your own syntax, but it is somewhat limited, and you might not get all the features you want from trying to make a catch-all lexer there.
Thanks a lot Peter.
If I simply need to add some tags to the current HTML language?
can I edit langs.xml in notepad++ folder,
and add tags to <Keywords…> part of the file?
<Language name=“html” ext=“html htm shtml shtm xhtml xht hta” commentLine="" commentStart="<!–" commentEnd="–>">
<Keywords name=“instre1”>!doctype a abbr accept accept-char
For the file to edit: If you have an installed copy (
%ProgramFiles(x86)%\Notepad++), then look first in
%AppData%\Notepad++\langs.xml: if there is a
langs.xmlthere, then edit that one. If you’ve got a portable version of Notepad++, or there isn’t a
langs.xmlthere, then you would edit the one in the same directory as
However, my quick experiment with a portable copy showed that it doesn’t recognize my new keyword when I do that for HTML.Some of the languages, like SQL's
KEYWORDstyle or Perl's
INSTRUCTION WORDstyle have “User-defined keywords”, which will get stored in
%AppData%\Notepad++for installed, or your exe-directory for portable), but the HTML lexer apparently doesn’t have any user-defined keywords.
Update: I was wrong. When I added “PeterAddedThis PeterAddedThat” to the end of the
langs.xml, it didn’t recognize it. But when I added “peter peteraddedthis peteraddedthat” in the alphabetically-correct location without capitalization, saved, then reloaded Notepad++, I could add
<peter added this></peter> <peterx></peterx> <peteraddedthis></peteraddedthis> <PeterAddedThat>hehe <peter></peter></PeterAddedThat>
and all but the
<peterx></peterx>would be highlighted as if they were real tags.
I then added “peteraddedlast PeterAddedX” to the end of the list (ie, not in alphabetical order). That made it recognize
<PeterAddedX></PeterAddedX>are not recognized.
So if you edit the right
langs.xml, and then add the keywords in lower case to the appropriate list, there is a good chance that you will see the added tags highlighted as valid HTML tags.
cool thanks for the effort