Community
    • Login

    keyword highlighting in text file

    Scheduled Pinned Locked Moved General Discussion
    17 Posts 4 Posters 2.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • venkyV
      venky @PeterJones
      last edited by

      @PeterJones Can you tell me how (steps) you applied the UDL? Thanks.

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @venky
        last edited by PeterJones

        @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:

        1. Copy your UDL text
        2. Paste into a new file
        3. Save As > %AppData%\Notepad++\userDefineLangs\TextUDL.xml
        4. File > Exit
        5. Run Notepad++
        6. Open text file (must have .txt extension)
          or
          File > New then File > Save As > c:\path\to\blah.txt
        7. Type file as
          Warning
          blah
          Error
          blah
          Failure
          blah
          
        8. 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).

        venkyV 1 Reply Last reply Reply Quote 0
        • venkyV
          venky @PeterJones
          last edited by

          @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

          npp issue.jpg

          PeterJonesP 1 Reply Last reply Reply Quote 0
          • PeterJonesP
            PeterJones @venky
            last edited by

            @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:

            1. Unzip Notepad++ portable to C:\usr\local\apps\npp\udl
            2. Copy C:\usr\local\apps\npp\udl\userDefineLangs\markdown._preinstalled.udl.xml to C:\usr\local\apps\npp\udl\userDefineLangs\TextUDL.xml
            3. Use MS notepad.exe to paste the exact UDL definition that you have above into TextUDL.xml and save/exit
            4. Create an emtpy file C:\usr\local\apps\npp\udl\blah.txt
            5. Drag blah.txt on top of notepad++.exe in that directory to run the portable instance with that blah.txt.
            6. Type (or paste) the six lines of the file.

            1af9de1c-a74c-4db4-9518-cbb7ca62629c-image.png

            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)
            
            Alan KilbornA 1 Reply Last reply Reply Quote 0
            • Alan KilbornA
              Alan Kilborn @PeterJones
              last edited by Alan Kilborn

              @PeterJones

              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).

              1131d953-08da-4f73-86ac-537da3b33a17-image.png

              And I didn’t get any coloring on Warning, Error, etc.

              PeterJonesP 1 Reply Last reply Reply Quote 0
              • PeterJonesP
                PeterJones @Alan Kilborn
                last edited by

                @Alan-Kilborn ,

                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.)

                Alan KilbornA 1 Reply Last reply Reply Quote 0
                • Alan KilbornA
                  Alan Kilborn @PeterJones
                  last edited by Alan Kilborn

                  @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. :-(

                  PeterJonesP 1 Reply Last reply Reply Quote 0
                  • PeterJonesP
                    PeterJones @Alan Kilborn
                    last edited by PeterJones

                    @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.

                    Alan KilbornA PeterJonesP 2 Replies Last reply Reply Quote 0
                    • Alan KilbornA
                      Alan Kilborn @PeterJones
                      last edited by

                      @PeterJones

                      OK, with the changeover from smart-quotes, all working for me as well:

                      7c804559-7a97-448c-90e3-2b7d1a027033-image.png

                      1 Reply Last reply Reply Quote 1
                      • PeterJonesP
                        PeterJones @PeterJones
                        last edited by

                        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 the Warning 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.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors