keyword highlighting in text file
-
@venky ,
There is nothing wrong with your UDL. When I apply that UDL to a file, I see:
or, in Dark Mode:
-
@PeterJones Can you tell me how (steps) you applied the UDL? Thanks.
-
@venky ,
You claim that “the UDL file is selected automatically under Language menu”, so according to your claim, it should be applied properly.
My steps were:
- Copy your UDL text
- Paste into a new file
- Save As >
%AppData%\Notepad++\userDefineLangs\TextUDL.xml
- File > Exit
- Run Notepad++
- Open text file (must have
.txt
extension)
or
File > New then File > Save As >c:\path\to\blah.txt
- Type file as
Warning blah Error blah Failure blah
- It’s highlighted
If it’s not working for you, please go to the ? menu, run Debug Info, click on the underlined text, and paste into your reply. In your reply, also show a screenshot with enough of the Status Bar to show us the selected language on the lower-left of the status bar (like my screenshot above).
-
@PeterJones Please see below. I put replaced user profile name with … in the path below.
I also tried this with portable version and it did not work.
Notepad++ v8.4.4 (64-bit)
Build time : Jul 15 2022 - 17:54:42
Path : C:\Program Files\Notepad++\notepad++.exe
Command Line :
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : C:\Users…\AppData\Roaming\Notepad++
OS Name : Windows 10 Enterprise (64-bit)
OS Version : 21H2
OS Build : 19044.1889
Current ANSI codepage : 1252
Plugins : none -
@venky said in keyword highlighting in text file:
I also tried this with portable version and it did not work.
I do not know what you are doing differently than I am.
I just started again from scratch:
- Unzip Notepad++ portable to
C:\usr\local\apps\npp\udl
- Copy
C:\usr\local\apps\npp\udl\userDefineLangs\markdown._preinstalled.udl.xml
toC:\usr\local\apps\npp\udl\userDefineLangs\TextUDL.xml
- Use MS notepad.exe to paste the exact UDL definition that you have above into TextUDL.xml and save/exit
- Create an emtpy file
C:\usr\local\apps\npp\udl\blah.txt
- Drag
blah.txt
on top ofnotepad++.exe
in that directory to run the portable instance with thatblah.txt
. - Type (or paste) the six lines of the file.
Notepad++ v8.4.4 (64-bit) Build time : Jul 15 2022 - 17:54:42 Path : C:\usr\local\apps\npp\udl\notepad++.exe Command Line : Admin mode : OFF Local Conf mode : ON Cloud Config : OFF OS Name : Windows 10 Enterprise (64-bit) OS Version : 20H2 OS Build : 19042.1889 Current ANSI codepage : 1252 Plugins : mimeTools (2.8) NppConverter (4.4) NppExport (0.4)
- Unzip Notepad++ portable to
-
I don’t want to muddy the waters, but when I follow the instructions, I just see
Normal text file
on the status bar after pulling in blah.txt. And, you didn’t show yours, but when I go to the UDL section of the Languages menu I don’t see anything that resembles “TextUDL” (and although I’m no expert on UDL, I expected to).And I didn’t get any coloring on Warning, Error, etc.
-
Yours is just behaving like you didn’t restart Notepad++ after putting the UDL definition in the userDefineLangs directory. (Or you used the wrong userDefineLangs directory)
Oh, actually, no, there was an implied step 3.5 which I forgot to mention: in notepad.exe, replace the “smart quotes” with real ASCII " quotes.
(I am working on a video screenshot , showing the full sequence… but having upload problems – new laptop, so my quick animation->forum process needs to be rebuilt.)
-
@PeterJones said in keyword highlighting in text file:
implied step 3.5 which I forgot to mention: in notepad.exe, replace the “smart quotes” with real ASCII " quotes
If it turns out the entire problem is the OP not pasting the data into a code block, I’m going to feel like my time was wasted. :-(
-
@Alan-Kilborn said in keyword highlighting in text file:
@PeterJones said in keyword highlighting in text file:
implied step 3.5 which I forgot to mention: in notepad.exe, replace the “smart quotes” with real ASCII " quotes
If it turns out the entire problem is the OP not pasting the data into a code block, I’m going to feel like my time was wasted. :-(
I hope that’s not all, too… I would have assumed that the OP would have just copied his UDL file over to the portable he tried, not just do a copy/paste from the forum. And since the OP status bar shows the TextUDL file type, obviously that part is working.
For @venky , here is a recording of the procedure I took, from unzipping through seeing the highlighting.
-
OK, with the changeover from smart-quotes, all working for me as well:
-
The other option, of course, is for @venky to start from scratch with a new UDL. Then build it up slowly, so that every piece is known working.
Here, I start with
blah.txt
, with the UDL editor docked. I switch to the default User Defined Language (so it really starts from scratch), Create New, give it a name (Second
), and switch the active language for just this file to Second.Then I go into keywords, use lowercase
warning
and give it a color, to show that it’s case sensitive. (I forgot while recording this second video that the screenshot above already showed theWarning
case matched what was in the pasted UDL definition)I go into the second keywords box with capitalized
Warning
, assign it a color, and watch the color change in the editor.If a user is having trouble getting a UDL to work, I recommend starting from scratch, and building it up slowly, because then you can see each individual step work.