Community
    • Login

    Is there a way to highlight section titles and have a content summary in Notepad++ ?

    Scheduled Pinned Locked Moved General Discussion
    13 Posts 3 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.
    • oelooO
      oeloo
      last edited by

      Hi, I am very often creating notes that look like the one below.
      Is there a way to highlight section titles and have a content summary in Notepad++ ? because when there is a lot of text it is not easy to navigate inside it.

      672519c9-c214-4693-a588-6dd7487a5264-image.png

      Title of this note
      
      1. Section title level 1
      1.1. Section title level 2
      Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
      
      1.2. Section title level 2
      Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
      
      1.2.1. Section title level 3
      Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
      
      1.2.2. Section title level 3
      Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.
      
      1.3. Section title level 2
      Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.
      
      
      2. Section title level 1
      Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. 
      
      
      3. Section title level 1
      3.1. Section title level 2
      Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.
      
      3.2. Section title level 2
      Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur.
      
      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @oeloo
        last edited by

        @oeloo

        It sounds like you are looking for a “word processor”.
        Notepad++ is a “text editor”.
        There’s a DIFFERENCE.

        oelooO 1 Reply Last reply Reply Quote 2
        • oelooO
          oeloo @Alan Kilborn
          last edited by

          I am not looking for a word processor. I want to only use plain text for many reasons (it is more cross-platform compatible).
          I just need an easier way to view/navigate inside.

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

            @oeloo said in Is there a way to highlight section titles and have a content summary in Notepad++ ?:

            I just need an easier way to view/navigate inside.

            I guess I’m not sure then what you expect a text editor to be able to do for you in this regard…do YOU have some specific ideas? If so, maybe we can make further suggestions…

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

              @oeloo said in Is there a way to highlight section titles and have a content summary in Notepad++ ?:

              I just need an easier way to view/navigate inside.

              My first thought after reading your request: since your file seems to have a pretty regular structure, where each section has an obvious #. prefix followed by a space then a title, you might be able to figure out a way to make a FunctionList definition for your file (View > Function List). Each “function” shown in the FunctionList could be one of your header lines, with its title text. Depending on your definition of “easy to view/navigate”, that configurable feature might be sufficient for you.

              Create a dummy User Defined Language (UDL) for your file type (I called it “Oeloo”; make it something meaningful to you): if it always uses the same unique extension (for example .oeloo), then put that in the extensions list for the UDL; if your file type has a generic extension (.txt), you might have to always manually select the UDL using Language > Oeloo to get the Function List to work.

              Once the UDL is created, you can create a FunctionList definition for that UDL. See the Useful Reference to figure out where the FunctionList definition goes, and what you need to change to get Notepad++ to do a FunctionList for that UDL.

              For the FunctionList “function name” regex, I would suggest something like one of the following:

              • If you want any level of header to be shown in the FunctionList panel, (?-s)^(\d+\.)+\h.* (to capture one or more instances of digit(s)-then-decimal-point as the prefix)
              • If you want just a few levels of header, then limit it; for example, if you want to show only level-1 or level-2 headers in the panel, then use (?-s)^(\d\.){1,2}\h.* (which only accepts 1. or 2.3. as prefixes, but will ignore 4.5.6.)

              After creating oeloo.xml in the right place (the functionList\ folder), and editing overrideMap.xml (in the same folder) to include that line, then restarting Notepad++, when you define a file as beeing Language > Oeloo, the Function List panel will show the outline, and double-clicking on the entries there will navigate to that location in your file. (If you had to use Language > Oeloo to change to the UDL language for your .txt file, you may have to hit the ⟳ refresh button in the panel to get it to show the Function List(

              Here’s are example oeloo.xml files for both use cases:

              • allows any number of levels in the list
                • a24ed85e-d2c0-417c-a073-2af5dde821d9-image.png
                • oeloo.xml:
                  <?xml version="1.0" encoding="UTF-8" ?>
                  <NotepadPlus>
                      <functionList>
                          <parser
                              displayName="Oeloo"
                              id         ="oeloo_outline"
                              commentExpr=""
                          >
                              <function
                                  mainExpr="(?-s)^(\d+\.)+\h.*"
                                  displayMode="$functionName">
                                  <functionName>
                                      <nameExpr expr="(?-s)^(\d+\.)+\h.*"/>
                                  </functionName>
                              </function>
                          </parser>
                      </functionList>
                  </NotepadPlus>
                  
              • only allows 1 or 2 levels of header in the list:
                • ce851bd0-155f-48cc-bef4-427975e5fe27-image.png
                • oeloo.xml:
                  <?xml version="1.0" encoding="UTF-8" ?>
                  <NotepadPlus>
                      <functionList>
                          <parser
                              displayName="Oeloo"
                              id         ="oeloo_outline"
                              commentExpr=""
                          >
                              <function
                                  mainExpr="(?-s)^(\d+\.){1,2}\h.*"
                                  displayMode="$functionName">
                                  <functionName>
                                      <nameExpr expr="(?-s)^(\d+\.){1,2}\h.*"/>
                                  </functionName>
                              </function>
                          </parser>
                      </functionList>
                  </NotepadPlus>
                  

              and finally, in my overrideMap.xml (described in the resources below), I use the following line to tell Notepad++ to use oeloo.xml for FunctionList definitions on the Oeloo UDL:

              <association id= "oeloo.xml"		userDefinedLangName="Oeloo"/>
              

              These examples should get you started.

              Note: I called it “Oeloo” after your username. But after generating all the files and screenshots, I realized I should have just called it “Outlining” or something similar, whereupon it would be generically useful. I didn’t feel like regenerating files/screenshots, but if you don’t have any other name in mind, “Outlining” might be a good name.

              Useful References

              • FAQ: Function List Basics
              • User Manual: Function List Overview
              • User Manual: Function List Config File info
              • User Manual: Config Files Location
              oelooO 1 Reply Last reply Reply Quote 5
              • oelooO
                oeloo @PeterJones
                last edited by

                @PeterJones Thank you for your nice suggestion.

                I have tried to use it but it seems I am missing a step. Here is what I have done following the instructions:

                1/ I have created the file C:\Program Files\Notepad++\functionList\oleoo.xml and copied your 1st example:

                <?xml version="1.0" encoding="UTF-8" ?>
                <NotepadPlus>
                    <functionList>
                        <parser
                            displayName="Oeloo"
                            id         ="oeloo_outline"
                            commentExpr=""
                        >
                            <function
                                mainExpr="(?-s)^(\d+\.)+\h.*"
                                displayMode="$functionName">
                                <functionName>
                                    <nameExpr expr="(?-s)^(\d+\.)+\h.*"/>
                                </functionName>
                            </function>
                        </parser>
                    </functionList>
                </NotepadPlus>
                

                2/ Then I have modified *C:\Program Files\Notepad++\functionList\overrideMap.xml by adding this line:
                d639cc12-5578-4168-a052-3ee7f81ae9bc-image.png

                3/ I have restarted Notepad++

                4/ I open my file with extension .oleoo*

                But I do not have Oleoo in the Language menu :
                995426fe-261e-4015-8e41-5ea9fda8fb36-image.png

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

                  @oeloo said in Is there a way to highlight section titles and have a content summary in Notepad++ ?:

                  But I do not have Oleoo in the Language menu :

                  As I said, “Create a dummy User Defined Language (UDL) for your file type”. Language > User Defined Language > Define Your Language. Save as Oeloo. Fill in oeloo in the Ext: entry. Since you created/loaded the file before you had defined the language, you will need to manually choose Language > Oeloo (it will be below the User Defined Language and not in the O submenu), and may need to ⟳ refresh the Function List and/or restart Notepad++ to get things in the right order (in my original description, creating the UDL came first; I don’t remember whether or not you have to restart if the UDL was created after the Function List was defined and N++ was restarted)

                  oelooO 1 Reply Last reply Reply Quote 2
                  • oelooO
                    oeloo @PeterJones
                    last edited by oeloo

                    I have added the entry UDL for Oleoo :
                    8b0ae456-1878-4e70-9ea7-4f6091843e48-image.png

                    Then I have the menu :
                    561a328e-0edd-4f01-a046-3a373d942bd4-image.png

                    But when I click on Oleoo in the above menu I get this :
                    d7ecc384-028c-4c97-a174-76a82d48cf29-image.png
                    What do I have these white highlightings ?

                    I have removed oleoo several times completely and re-done the process exactly as you wrote. I have also fully restarted my PC each time to be sure of the result.

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

                      @oeloo ,

                      Any UDL defaults to black text on white background; when you have a dark theme, that conflicts. (By dark theme, I mean Dark Mode, and/or any of the themes that use light-text-on-dark-background)

                      To fix your UDL text colors: go to Language > User Defined Language > Define Your Language, choose Oeloo from the drop-down. Click Styler in the Default Style, and right-click on both Foreground color and Background color’s color box. And un-checkmark the Bold/Italic/Underline boxes, if they are checkmarked.

                      Now the dummy UDL “Oeloo” will inherit the colors from your active theme.

                      Before:
                      f925362a-6e17-4de4-8f54-41857f042471-image.png

                      After:
                      ab511e71-c164-4d19-a0cd-0b5ac77cc601-image.png

                      —
                      update: nearly four years ago, issue #5622 was submitted to request that new UDLs should use the active theme. You might want to upvote that request, though after languishing 4 years, I am doubtful any action will be taken on that request.

                      oelooO 1 Reply Last reply Reply Quote 3
                      • oelooO
                        oeloo @PeterJones
                        last edited by

                        @PeterJones
                        I have modified the UDL according to the instructions:
                        19b8d011-d482-46a7-b290-0bb452babe59-image.png

                        The highlighting in white of the whole text is fixed, but I have the number at the end of lines still highlighted in white:
                        24dba0a0-2494-49ad-ad0a-c720ba72b675-image.png

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

                          @oeloo ,

                          After you saw that numbers still looked weird, did you try to explore the rest of the UDL dialog, looking for ways to change the colors? Did the tab name Comment & Number not tell you “here would be the place to change the colors for Numbers”? When you went there, did you try changing the Styler for numbers?

                          Since you had to ask this folloup, I am forced to conclude “No” is the answer to all those. Then why not? I can understand the original confusion, because I hadn’t mentioned stylers (because I didn’t realize it was relevant to you). But now that I’ve pointed out that button, I don’t understand why you didn’t at least look for similar color settings throughout the UDL dialog for setting the colors for the numbers.

                          oelooO 1 Reply Last reply Reply Quote 1
                          • oelooO
                            oeloo @PeterJones
                            last edited by

                            @PeterJones
                            The tab named ‘Comment & Number’ does not show this sentence:
                            bd13f681-c922-41ed-94c6-011933cb31a3-image.png

                            did you try to explore the rest of the UDL dialog, looking for ways to change the colors?
                            When you went there, did you try changing the Styler for numbers?
                            I did not tried to change anything else, I changed directly what you recommended.

                            But now that I’ve pointed out that button, I don’t understand why you didn’t at least look for similar color settings throughout the UDL dialog for setting the colors for the numbers.
                            Which Styler button are you referring to: the one in ‘Number style’ ?

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

                              The tab named ‘Comment & Number’ does not show this sentence:

                              Sorry, I assumed that “did you try changing the Styler for numbers” would lead you to the “Number Style” section to click on the Stylers button.

                              I did not tried to change anything else, I changed directly what you recommended.

                              For the first problem – the main text showing up inverted – that makes sense. But when you had a problem with numbers, I would have hoped that you would learn from the first lesson and generalize. I cannot possibly anticipate every problem you might have, and, as my time in this forum is just on a volunteer basis, I cannot spend all my time exploring every possible problem someone might have implementing my advice.

                              Which Styler button are you referring to: the one in ‘Number style’ ?

                              Yes.

                              43757ba7-04d7-4012-a7c8-f68429bb12c1-image.png

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