Language, User Defined
-
Hi,
I can’t get styling to work where an equal sign is used. I have this text:
Sheppard, Betty Natalie (26 Feb 1929 ~ 18 Dec 1997), MaidenName=DAVIES
I want to highlight “MaidenName=”, but since it is immediately followed by “D” it will not highlight, it works in a “word” mode unless prefix mode is selected and that highlights more than I want.
Is there anyway to simply highlight the text I want/specify? If so is there a way to do so using regular expressions? I only want to do this for the language I created (or for specific file extensions).
Notepad++ v8.7.5 (64-bit)
Build time : Dec 21 2024 - 05:13:03
Path : C:\Program Files\Notepad++\notepad++.exe
Command Line : -n9999 “D:\DBAREIS\FamilyTree\FAG (cemetery visits)\Victoria\Bunurong Memorial Park, Dandenong, (very pretty place with lake)-Betty Natalie Sheppard (26 Feb 1929~18 Dec 1997).GenealogyResearch”
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
Periodic Backup : ON
Placeholders : OFF
DirectWrite : OFF
Multi-instance Mode : monoInst
File Status Auto-Detection : cdEnabledNew (for current file/tab only)
Dark Mode : OFF
OS Name : Windows 11 Pro N (64-bit)
OS Version : 24H2
OS Build : 26100.2894
Current ANSI codepage : 1252
Plugins :
GedcomLexer (0.5.0.170)
MenuIcons (2.0.1)
mimeTools (3.1)
NppConverter (4.6)
NppExport (0.4)
Remove Duplicate Lines (1.3)
RunMe (1.6)
zoomdisabler_x64 (1.2) -
No, the standard UDL does not allow the use of regular expressions. One way to work around this would be to use the EnhanceAnyLexer plugin.
Regarding MaidenName=: If this is always the last expression in the line you could use a delimiter where open is the equals sign and close =((EOL))
. -
@Dennis-Bareis said in Language, User Defined:
Is there anyway to simply highlight the text I want/specify?
Instead of highlighting keyword
MaidenName=
, you could highlight the keywordMaidenName
(not in prefix mode) and include=
in the Operators1 list (which doesn’t require separators around the operator)Here is an example where
MaidenName
is in keywords1 (not prefix, bold+red), and=
is in operators1 (background=yellow):But you could of course set both the keywords and the operators to the same color, if you wanted them to blend together, like this (where I changed the operators to bold+red):
-
@PeterJones said in Language, User Defined:
Instead of highlighting keyword
MaidenName=
, you could highlight the keywordMaidenName
(not in prefix mode) and include=
in the Operators1 list (which doesn’t require separators around the operator)Thanks, that is a great workaround for me anyway. The workaround could potentially effect other things, but it works well enough for now :-)
Its a bit disappointing that NPP can’t simply highlight text as is. As I am the one defining the format of this file, I shouldn’t have any issues…
-
@Dennis-Bareis ,
Depending on which one of these two answers you were referring to, the second one by @PeterJones is not a work around. That is the way the User Defined Language system works. You 'd know that if you read the user manual regarding that feature. -
@Ekopalypse said in Language, User Defined:
No, the standard UDL does not allow the use of regular expressions. One way to work around this would be to use the EnhanceAnyLexer plugin.
That plugin is also a great suggestion, I will play around with this also.
Regarding MaidenName=: If this is always the last expression in the line you could use a delimiter where open is the equals sign and close =
((EOL))
.Thanks for the idea but this wouldn’t work in my case :-)
-
Thanks for the link, I’ll look next time I need to.
It is a workaround for User Defined Language limitations (which the mentioned plugin improves on). And better apps will point you to the documentation rather than you having to somehow discover it. In any case who would immediately understand it unless your name is Einstein, which mine isn’t (hence needing the help).
-
@Dennis-Bareis said,
And better apps will point you to the documentation rather than you having to somehow discover it.
The ? menu in Notepad++ is obviously for help. The Notepad++ Online User Manual link in that menu takes you to the documentation, and is quite easy to find, even for a non-einstein like me. And the UDL dialog accessible from Language > User Defined Language > Define your language… actually has a clickable URL which goes to the original ivan-radic documentation for the UDL system – and that’s the site which originally explained in precise detail exactly how the operators and keywords work, so it would have been a different location, but the same information. I’m not sure how much more a “better app” could point you to the documentation than Notepad++ is, especially in regards to UDL documentation.
(I know that some dialogs in some applications have a ? button for popping up the specific help on a specific field; but while I saw that more frequently a few years ago, I don’t notice it on many modern apps anymore, so I don’t know if it ever really made it into common use. Other than that, I cannot think of anything more blatant than what Notepad++ already gives you for pointing to documentation.)
Its a bit disappointing that NPP can’t simply highlight text as is.
What’s that supposed to mean? My example proves exactly the opposite of what you said.
Every programming language or other structured language that I have ever heard of or imagined, if using a construct like
MaidenName=DAVIES
, would treat the=
separately fromMaidenName
– the=
would be the assignment operator, and theMaidenName
would be a keyword or a variable name. The text, as it is, was a keyword followed by an operator; you were trying to treat the operator as part of the keyword, which is why you were having difficulty.I don’t claim that you would have understood the documentation immediately (or that anyone would), but documentation is always a good place to start when you are looking for help; and looking in the ? or Help menu of an application is where one goes to find the documentation.
It is not a workaround when it’s working as designed, and as the structure of the text warrants – the structure of the text shows the
=
being an operator, so that’s how you need to treat it.If you end up using the extra power of EnhanceAnyLexer, that would be a work around; but for the exact situation you described, no work around is necessary; you just needed help learning how to use the tool as it was designed, which is fine.
-
@Dennis-Bareis ,
You have to understand, the UDL uses a complex, but pretty thorough general purpose lexer that anyone that takes the time to learn the UDL documentation and system, (and it doesn’t happen overnight) can make some pretty good User Defined Language Packages. I say package, because right now, short of the Visual UI designer in my dBASE IDE, I can use Notepad++ for a damn good IDE. It took me about a year to complete (not constantly working on it) the UDL and it includes several customizations of NPP basic features to do it.- Syntax Highlighting - basic, I’m working on advanced now.
- Auto Completion - Entire language documented and hints available
- FunctionList - Entire language Class/Method/Functions usable for navigation
- Popup Context Menu that has the dark/light language options selectable and will soon include multiple versions of our legacy language UDL’s with options chosen by right click navigation.
- Snippets - Setup with our language specific code for pasting
- UDL Specific Macros for Header insertions
- Plugins that allow this development environment to process things that our IDE doesn’t even touch, with the option to use other plugins
- Theme, dark mode, color control, that our IDE lacks…etc.
- Replace the NPP help F1, that calls up the dBASE Help documentation
The list can go on. Everyday I learn things. Look at it like this. If you want to make a quality UDL for yourself…slow down and take the time to learn this system, so that short of writing your own Lexer/Parser you can make a pretty good package fairly quickly.
dBASE, that I made the package for, is more difficult for the UDL to address all things, because it’s a loose language that allows some legacy procedural code, Visual UI creation, database manipulation language, OOP Object’s and language etc. So if I can figure this out, you can. I’m no Einstein, but I had a lot of persistence, an open and positive attitude wanting to learn all of this from scratch, including learning NPP’s version of regex and regex in general.
But try not to come here frustrated because you don’t get a red carpet roll out of how to do things. It’s not easy being a product that can do a lot for a lot of people. Maybe not everything, but so far I’ve found the only thing lacking here, is my own knowledge of how to do it…and that’s what you have to understand. You’re learning their eco system…so try to learn it and not complain about what you don’t understand yet. Please. You get more bees with honey, than vinegar.