How to highlight numbers WITHIN words
It seems like such a simple feature I feel like I must be doing something wrong.
I have already tried toggling the setting “Match whole word only” in Preferences>Highlighting>Smart Highlighting. It seems to have no effect for this issue.
I’ve also tried getting it done with UDL. As you can see in the screenshot, I can get numbers to highlight in the middle of ‘words’(really just characters surrounded by whitespace) only if they are surrounded by operators. For example I can add the character
'to the Operators 1 field and it will highlight the rest of those instances of “3479”.
Furthermore I gather that there is no ((SPACE)) keyword that I can use in UDL like there is for ((EOL))? That would help with my UDL greatly.
see here https://ivan-radic.github.io/udl-documentation/numbers/ if this can help.
I have already tried toggling the setting “Match whole words only”
Preferences>Highlighting>Smart Highlighting only affects what is shown when you manually select a piece of text: if you select 314159 here, then it will look like:
Any Whole Words Only
But that will only show you exactly the digits that are currently selected – so it finds the digits of pi, but not the digits of e, since the digits of pi are the ones I had selected.
That option does not affect UDLs.
I wasn’t sure if that was tried as a way to change the behavior of the UDL, or if that “match whole word only” was meant to affect something else other than manually selecting text and having it highlight all other text that matches the selection.
If you couldn’t think of other ways to manually select/mark digits: use the Search > Mark (
Ctrl+M) and use a regular expression to manually mark all strings of digits.
But given your focus on UDL in the rest of your question, I wonder if you are really just trying to change UDL behavior. You cannot do that with any of the options in the Preferences dialog; UDL is controlled via the UDL dialog/panel and that’s it.
As far as UDL syntax goes: no, there is no
((EOL))is the only fancy escape… well, except for enclosing a term in quotes:
"key word"will match
key wordbut not
key other word
The quote-around-spaces works for keywords and folding-in-code-2, but in my experiments today, I couldn’t get it to work in folding-in-code-1 or comment-line or operators or delimiters. So that might work for your ((SPACE)) desire, in certain circumstances.
If you’re really looking to highlight extra numbers that are in weird situations and would like to be able to use a regex but otherwise treat it as a UDL, you can use @Ekopalypse’s Enhance Any Lexer. For example, if I have a UDL called “voltaire” which uses an aqua-like color similar to what you have for its “number style”, and in Enhance Any Lexer, set
[voltaire] 0xFFFF00 = (?<=[\l\u_])\d+|\d+(?=[\l\u_])
which will set digits to bright cyan if they have upper or lowercase or underscore to the left or right; otherwise, if the UDL thinks of it as a “word” of numbers (spaces or operators to either side), then the UDL will highlight them with the aqua.