Advanced Syntax Highlighting Customizations
-
I want to add text color to user classes and typdef variable types, but I can’t figure out how to do this with NPP. In addition I would like to add my own subset of keywords which would appear inside strings, and I would like to add highlighting to constant variables. I would also like to be able to apply tints like a background with an alpha to create more color differentiation that works with any background. I have not found a way to do this in the GUI nor by attempting to edit the XML files for NPP. It should be relatively simple as this syntax is designed so it can be understood at compile time already. you would just be using keywords/sets of keywords as your deliminators. If anyone knows how to do this in notepad++, please tell me. I came across an IDE that let me do this once, but I can’t remember what it was and if NPP has that I would greatly prefer NPP. I am going to be switching to NPP for all my code writing so it would be nice to figure out how to add this syntax highlighting. Thanks.
-
Try the
Language -> Define your language...
menu there you can define your keywords and a lot of stuff.You can then export them and import them too.
Check this: http://docs.notepad-plus-plus.org/index.php/User_Defined_Language_Files to see some examples of user defined languages (UDL) you can import.
-
I’ve seen this and looked through the define your own language, but there wasn’t any way I could find to add highlighting to user defined types and classes. I can add keywords with it though. I can’t seem to add cpp from that list(probably because it’s built in by default) so I would have to manually reenter everything for Cpp. If you know where I can get a cpp language syntax file to import that would be a great start. the highlighting I would want is as follows
typedef double aFloatValue;
typedef integer anIntegerValue;
typedef char aCharacterValue;in this case I would want to ad highlighting to aFloatValue, anIntegerValue, and aCharacterValue.
class myNewClass
{
public:
//code…
private:
//code…
}class myNewClass2
{
public:
//code…
private:
//code…
}in this case I would want myNewClass and myNewClass2 to have a different highlighting from the typedef above.
then I would also want to be able to add highlighting to variables such as:
double dnum;
int num;
char character;where dnum, num, and character should have a style for highlighting separate from classes and typedefs.
the user defined languages don’t seem to allow for this functionality at all, and I can’t find cpp in the list of files.
-
the cpp lexer needs to be modified in this case.
You need to either change it yourself
https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/scintilla/lexers/LexCPP.cxx or you may ask scintilla devs at https://sourceforge.net/p/scintilla/feature-requests/ to add this but the later means also, once it has been done, that you ask Don to update the scinitilla library npp is using.Cheers
Claudia -
Thanks for pointing me in the right direction. I took a look at the code and it looks more involved than I want to get. While writing the functions would be simple I’m not confident I could make it play nice and interface with that program without investing more time than it’s really worth. I’ll put in the request I think. Thanks again though, you’re the first person who’s pointed me to something useful.