• Login
Community
  • Login

can i use function list in Notepad++ 7.9.5?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
13 Posts 6 Posters 3.7k 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.
  • B
    bge low
    last edited by bge low May 10, 2021, 8:44 AM May 10, 2021, 8:43 AM

    i want outliner for mark down file.
    i just want the header like vs code,not the markdown preview.
    markdown.JPG
    is it possible by extension?

    P 1 Reply Last reply May 10, 2021, 1:26 PM Reply Quote 1
    • P
      PeterJones @bge low
      last edited by May 10, 2021, 1:26 PM

      @bge-low ,

      Is it possible by extension?

      If by “extension” you meant “plugin” – that’s not necessary, at least for the first-level of what you requested; as shown below, it will work with builtin Notepad++ features.

      If by “extension”, you mean “file extension”, then yes; if your Markdown UDL defines the ext box as md markdown or similar, any files ending in .md or .markdown will have the Markdown UDL lexer applied automatically, and will also have the functionList feature applied if you’ve followed the steps described below. (Since there is a pre-installed Markdown UDL included with Notepad++, and it does define the extensions, then it will probably work by extension without extra effort beyond what’s described below.)

      Instructions

      Notepad++ has the built in Function List tool, which is meant for showing functions, classes, and the like. However, to some extent, it can be used to find the headers in markdown.

      To accomplish this, follow the instructions in the npp-user-manual.org Function List page as well as the Function List config files section

      1. Exit all instances of the Notepad++ application
      2. Edit %AppData%\Notepad++\functionList\overrideMap.xml .
        Just before the ending </associationMap>, add a line
        <association id= "markdown.xml" userDefinedLangName="Markdown (preinstalled)"/>
        
        If you have an unedited copy of overrideMap.xml, putting it in the group with the other example UDL is a good idea:
        692985a6-28e3-4b9f-9784-5444fc537991-image.png
        and Save overrideMap.xml
      3. Edit %AppData%\Notepad++\functionList\markdown.xml. Give it content like the following:
        <?xml version="1.0" encoding="UTF-8"?>
        <!-- ==========================================================================\
        |
        |   To learn how to make your own language parser, please check the following
        |   link:
        |       https://npp-user-manual.org/docs/function-list/
        |
        \=========================================================================== -->
        <NotepadPlus>
            <functionList>
                <parser displayName="Markdown (preinstalled)"
                        id="Markdown (preinstalled)"
                        commentExpr="">
                    <function mainExpr="(?x-s)(^[#]+\s*(.*?)$|^(.*)(?=[\r\n]+^([-=])\4{2,}\s*$))"/>
                </parser>
            </functionList>
        </NotepadPlus>
        
        The function expression will recognize markdown headers that are prefixed with one or more #, or headers that are indicated by a following line consisting of --- or ===. If you have other requirements, you can add them into the regular expression
        Save markdown.xml
      4. Exit Notepad++ and re-start the application (required to get it to re-read the config files)
      5. Now when you open a Markdown file in Notepad++, the View > Function List panel will show the outline, like in my screenshot below.

      16a8abf5-5b13-4cdf-a189-898dc7aa293a-image.png

      As you can see, it doesn’t make a multi-layer hierarchy, like you showed… but since it keeps the # prefixes, you can still see which level of hierarchy you are on. Using the “class” feature of the Function List syntax (see the FAQ, linked below), you could make it give one level of hierarchy, though it would require some additional development on your part to update the markdown.xml contents per the FAQ and npp-user-manual.org instructions. And personally, I don’t think a single layer or hierarchy is worth the effort for Markdown “functionList” features.

      References:

      • FAQ: Function List Basics
      • npp-user-manual.org section: Function List
      • npp-user-manual.org section: Config Files > Function List
      A B T 3 Replies Last reply May 10, 2021, 2:29 PM Reply Quote 4
      • A
        Alan Kilborn @PeterJones
        last edited by May 10, 2021, 2:29 PM

        FYI, I followed Peter’s instructions and it worked perfectly.
        I was somewhat of a risk-taker and skipped step 1, with no problems. :-)

        1 Reply Last reply Reply Quote 0
        • A
          Alan Kilborn
          last edited by May 10, 2021, 2:42 PM

          @PeterJones

          I notice that the dynamic highlight color in the Function List of the function your caret is in in the editor window is rather subtle (using the default theme).
          In case it is unclear, I mean as you caret around in your main document area, the Function List shows you which “function” you are currently in.
          I don’t mean when you click on a function in the FL window – when I do that, the background highlight of the function clicked is suitably contrasting.

          For me the background coloring is much more subtle than your screenshot shows for ## Another Level 2.

          Is there a technique for making this more visible (i.e., making the background color of that function name darker)?

          This feels like it might have been something discussed before?

          1 Reply Last reply Reply Quote 1
          • G
            guy038
            last edited by guy038 May 10, 2021, 10:27 PM May 10, 2021, 8:29 PM

            Hello @bge-low, @peterjones, @alan-kilborn and All,

            After some tests on our NodeBB forum and some searches on legal Markdown syntax, I think that we should change the present syntax :

                        <function mainExpr="(?x-s)(^[#]+\s*(.*?)$|^(.*)(?=[\r\n]+^([-=])\4{2,}\s*$))"/>
            

            into this new one :

            
                        <function mainExpr="(?-s)^#{1,6}(?:(?=[\t\x20]*$)|[\t\x20]+\K.+)|^.+(?=\R\x20{0,3}[-=]+[\t\x20]*$)"/>
            

            You may test it against this text, using the Markdown (preinstalled) language :

            Line 1
            Line 2
            ###### HEADER Text of level 6
            Line 3
            Line 4
            Line 5 is a HEADER line
            =======	        	
            Line 6
            Line 7 is ALSO a HEADER line
               -
            Line 8
            Line 9
            
            # Level 1 HEADER Text
            Line 10 : the NEXT line is an EMPTY HEADER text
            ###
            Line 11
            Line 12
            

            With the free-spacing mode, this regex can be re-expressed as below :

            (?x-s)                 #  FREE-SPACING mode and any DOT matches a SINGLE STANDARD char ONLY
              ^ \# {1,6}           #     From 1 to SIX '#' characters ...
              (?:                  #     START of a NON capturing group 1 
                (?= [\t\x20]* $ )  #       IF followed with POSSIBLE TAB or SPACE character(s) till the END of CURRENT line
              |                    #     OR
                [\t\x20]+          #       followed with, at least, one TAB or SPACE character
                \K .+              #       and, AFTER a RESET, followed with the REMAINDER or CURRENT line
              )                    #     END of the NON-CAPTURING group 1
            |                      #   OR
              ^.+                  #     CURRENT line contents ...
              (?=                  #     Start of a POSITIVE look-ahead
                \R\x20{0,3}        #       IF followed with A LINE-BREAK, and from ZERO to THREE SPACE character(s)
                [-=]+              #       followed with, at least, ONE DASH or EQUAL sign
                [\t\x20]*$         #       Followed with POSSIBLE TAB or SPACE character(s) till the END of CURRENT line
              )                    #     END of the POSITIVE look-ahead
            

            Best Regards,

            guy038

            1 Reply Last reply Reply Quote 2
            • B
              bge low @PeterJones
              last edited by May 11, 2021, 3:39 AM

              @PeterJones
              thanks peter.your tutorial worked perfectly.

              but i still have other question.
              can the function list be “fold” like vs code?
              header1 locate in top,header2 and header3 locate in under of header1.

              A 1 Reply Last reply May 11, 2021, 11:23 AM Reply Quote 0
              • A
                Alan Kilborn @bge low
                last edited by May 11, 2021, 11:23 AM

                @bge-low said in can i use function list in Notepad++ 7.9.5?:

                but i still have other question.
                can the function list be “fold” like vs code?

                I think Peter answered this one:

                As you can see, it doesn’t make a multi-layer hierarchy

                So the very short answer is No.

                1 Reply Last reply Reply Quote 1
                • B
                  bge low
                  last edited by May 12, 2021, 11:36 AM

                  thanks for comment.do i have to develop for folding function?
                  that looks like very hard.

                  A 1 Reply Last reply May 12, 2021, 11:42 AM Reply Quote 0
                  • A
                    Alan Kilborn @bge low
                    last edited by May 12, 2021, 11:42 AM

                    @bge-low said in can i use function list in Notepad++ 7.9.5?:

                    do i have to develop for folding function?

                    If you want that feature, I’d say Yes.
                    Otherwise you can make a FEATURE REQUEST for the N++ developers, but that offers no guarantee of implementation.

                    B 1 Reply Last reply May 13, 2021, 2:10 AM Reply Quote 2
                    • B
                      bge low @Alan Kilborn
                      last edited by May 13, 2021, 2:10 AM

                      thanks for comment.
                      i may have to make plugin.
                      https://npp-user-manual.org/docs/plugins/

                      1 Reply Last reply Reply Quote 0
                      • T
                        Theodan23 @PeterJones
                        last edited by Jan 5, 2025, 12:02 AM

                        @PeterJones Thanks so much for documenting this. There are several older posts on various sites about how to modify the Function List, but they no longer work since Notepad++ introduced newer mechanisms for managing all this, e.g. overrideMap.xml.

                        It should be noted that there seems to be a bug in Notepad++ related to this.

                        You must make the file changes above within the %AppData%\Notepad++\functionList dir, which means it has to be done separately for each user of the PC.

                        Trying to instead make the same changes for all users of the PC, within the C:\Program Files\Notepad++\functionList dir, results in Notepad++ entirely ignoring the configuration.

                        Given that the C:\Program Files\Notepad++\functionList dir exists and has the same files, including the overrideMap.xml mechanism, leads me to think that its being ignored is a bug in Notepad++.

                        P mpheathM 2 Replies Last reply Jan 5, 2025, 12:17 AM Reply Quote 1
                        • P
                          PeterJones @Theodan23
                          last edited by Jan 5, 2025, 12:17 AM

                          @Dan-Ignat-0 said in can i use function list in Notepad++ 7.9.5?:

                          It should be noted that there seems to be a bug in Notepad++ related to this. …

                          Makes sense, but we cannot do anything about it in the Community Forum. If you want the developer to hear your thoughts, follow our Feature Request / Bug FAQ to put your request in the official tracker.

                          1 Reply Last reply Reply Quote 0
                          • mpheathM
                            mpheath @Theodan23
                            last edited by Jan 5, 2025, 2:56 AM

                            @Dan-I-2072 said in can i use function list in Notepad++ 7.9.5?:

                            You must make the file changes above within the %AppData%\Notepad++\functionList dir, which means it has to be done separately for each user of the PC.

                            Trying to instead make the same changes for all users of the PC, within the C:\Program Files\Notepad++\functionList dir, results in Notepad++ entirely ignoring the configuration.

                            The all users path might be %ProgramData%\Notepad++\functionList or the older Environmental Variable path of %ALLUSERSPROFILE%\Notepad++\functionList. I do not know if Notepad++ searches in those paths.

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