Community
    • Login

    Scroll and search through keyword lines by alphabetical order?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 295 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.
    • X
      X88R88
      last edited by

      How can one scroll and search through main keywords only? Bookmarking keyword lines isnt permanent and cant scroll or search through them alphabetically.

      Aluminum-
      notesnotesnotes

      Boron-
      notesnotesnotes

      Copper-
      notesnotesnotes

      Dysprosium-
      notesnotesnotes

      Europium-
      notesnotesnotes

      Fluorine-
      notesnotesnotes

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

        @X88R88

        Presume your “keyword” is some text at start of line followed by - followed by a line-ending.

        If so, make a macro to bookmark that line using a regular expression search of ^\w-$. Assign the running of that macro to an unused keycombination.

        To counter the “isn’t permanent” complaint, run the macro by pressing the keycombo when you need it.

        Regarding “alphabetically”, they already appear alphabetic. But, if they weren’t, there wouldn’t be a simple way to “search through them alphabetically”.

        Alan KilbornA 1 Reply Last reply Reply Quote 2
        • Mark OlsonM
          Mark Olson
          last edited by Mark Olson

          @Alan-Kilborn 's suggestion is reasonable, though I would use (?i)^[a-z]+-$ to mark lines that contain only element names followed by a - because every element name contains only ASCII letters.

          The JsonTools plugin features a treeview that can show all the search results for a regex search and jump to their locations in the document.

          For example, if I have this document:

          Hydrogen-
          foo
          bar baz
          
          Helium-
          foo
          bar baz
          
          Lithium-
          foo
          bar baz
          
          Beryllium-
          foo
          bar baz
          
          Boron-
          foo
          bar baz
          
          Carbon-
          foo
          bar baz
          
          Nitrogen-
          foo
          bar baz
          

          the query sort_by(s_fa(@, `(?s)^(\w+)-\r\n(.*?)\r\n\r\n`, false), 0) (entered in the text box at the top of the treeview) will allow you to scroll through the elements in alphabetical order using the treeview.

          14b7d725-d62f-45a8-854b-09b9b8624b5d-image.png

          I have also created a PythonScript script that lets you sort multi-line blocks of a document alphabetically, but I don’t think that’s the best solution here because it changes the document, and you just want to iterate through it in a non-standard order.

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

            @Alan-Kilborn said in Scroll and search through keyword lines by alphabetical order?:

            ^\w-$

            I intended it to be ^\w+-$ but the + got lost somehow. :-(

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