Community
    • Login

    I want to make a really long list

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 3 Posters 1.0k 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.
    • A DA
      A D
      last edited by

      I want to make a list with indents and increments of numbers repeating something like this but I will do it for many more lines that’s why I need a command

      1
      1.
      2.
      3.
      2
      1.
      2.
      3.
      4.
      5.
      3
      1.
      2.
      3.
      4.
      5.
      6.

      and so forth or if there is some kind of website that does this that be cool to know too

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

        @A-D

        To do this one really needs a “pattern” for the general case. I’m not seeing the pattern in the sample data provided.

        A DA 1 Reply Last reply Reply Quote 0
        • PeterJonesP
          PeterJones
          last edited by

          @A-D said:

          I want to make a list with indents and increments of numbers repeating

          And, as @Alan-Kilborn said, we’d need to know what your pattern is for determining how far to indent, and how many levels of indent you wanted.

          If, as your example shows, you are literally using “number without dot” to indicate a left / no-indent line, and “number with dot” to indicate a line that you need to indent (I’ll assume 4 spaces), then it’s pretty easy with two regular expressions

          Start with

          1
          1.
          2.
          3.
          2
          1.
          2.
          3.
          4.
          5.
          3
          1.
          2.
          3.
          4.
          5.
          6.
          

          First regex should be find = ^\h*(\d+[^\.]), replace = $1, which will pull all the number-without-dot to the far left.
          Second regex should be find = ^\h*(\d+\.), replace = \x20\x20\x20\x20$1, which will indent all number-with-dot rows four spaces to the right (the four \x20 are used to make the number of spaces obvious; in a regex replace, \x20 is equivalent to a literal space character.)

          If, as I strongly suspect, the dot-vs-no-dot was really an artifact of the way you pasted your data, then I doubt any regex is going to be able to really satisfy you, so the solution isn’t going to be native to Notepad++. Instead, it sounds like a job for a programming language. You would have to define exactly what you wanted the “before” and “after” to be like, and then code up the logic in your favorite programming language.

          If you know Python or Lua or Javascript, you could use the plugins PythonScript, LuaScript, or jN Notepad++ Plugin, which will give your favorite programming language direct access to the live contents of the Notepad++ editor window.

          My first guess at the logic, in pseudocode, would be: “if this line’s number is less than or equal to the previous line’s number, then increase indent; if this line’s number is exactly equal to 1 + the previous line’s number, then keep the same indent; otherwise, decrease indent by 1.” I’d then probably adjust the logic slightly, because “previous line” takes on a different meaning after you’ve decreased the indent. I can think of lots of edge cases, so you’ll have to be careful.

          What exactly the final code will look like depends on how many indentation levels you would allow, and what the exact rules are for determining when you think it should indent more or outdent.

          It might be an interesting quick programming challenge, but nothing about the algorithm itself is specific to Notepad++. It could be a cookie-baking problem, because you can type the code in Notepad++. And it can be run from within notepad++ with access to the contents of open files by using a scripting plugin. But in the end, making that code isn’t really a Notepad+±specific question.

          Alan KilbornA A DA 2 Replies Last reply Reply Quote 1
          • Alan KilbornA
            Alan Kilborn @PeterJones
            last edited by

            @PeterJones

            Bah. Too much effort put into a reply to something the OP put little initial thought into. Save your energies for important things. :)

            1 Reply Last reply Reply Quote 0
            • A DA
              A D @PeterJones
              last edited by

              @PeterJones thanks I use notepad initially when I started cuz of line operations so I thought to ask thank you for your thorough answer

              1 Reply Last reply Reply Quote 0
              • A DA
                A D @Alan Kilborn
                last edited by

                @Alan-Kilborn the example wasn’t for a pattern I just assumed doing something like that was possible I guess I was looking for the principle of the answer not the exact answer to the particular numbers

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