Community
    • Login

    how to add more then 1024 new lines at once?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    21 Posts 6 Posters 3.4k 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 MRB
      B MR
      last edited by

      hi,
      i’m trying to add about 3000 new lines at once,
      between lines
      but no luck
      it has a limit of 1024
      i used search and replace
      search for $
      replace with \n\n - up to 3000 times…
      any ideas?

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

        @B-MR

        You could record a macro that inserts ONE line-ending, save it and name it, suggest “Insert a Line-Ending”.
        Then use the Run a Macro Multiple Times command and specify that you want to run it 3000 times:

        3b278a91-e9f8-4208-a9ba-c653ca7aea10-image.png

        For all this see the Macro top-level menu.

        Alternatively, to do it all in a single step, without having to invoke the Run a macro box, you could make a macro that inserts 3000 line-endings, and tie that to a keycombo for easy repetitive use.

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

          @Alan-Kilborn said in how to add more then 1024 new lines at once?:

          you could make a macro that inserts 3000 line-endings

          Note that I’m not suggesting recording that many manual presses of the Enter key! I’m suggesting to take the macro that inserts ONE and hand-edit shortcuts.xml to do a copy+multiple-paste change of the text of the macro, into a different, appropriately named macro.

          B MRB 1 Reply Last reply Reply Quote 3
          • B MRB
            B MR @Alan Kilborn
            last edited by B MR

            @Alan-Kilborn
            i tried, recorded search and replace of $ and \n
            then run… still running, close to an hour
            (300 lines),

            didn’t understand what to copy/paste

            Alan KilbornA PeterJonesP 2 Replies Last reply Reply Quote -1
            • Alan KilbornA
              Alan Kilborn @B MR
              last edited by

              @B-MR said in how to add more then 1024 new lines at once?:

              i tried, recorded search and replace of $ and \n

              Why would you do that?
              Who said to do that?
              Ok, well maybe I wasn’t super clear.

              Here’s how macro recording would go:

              • start macro recording
              • in editor window, press the Enter key once
              • stop macro recording
              • save macro
              1 Reply Last reply Reply Quote 4
              • PeterJonesP
                PeterJones @B MR
                last edited by PeterJones

                @B-MR ,

                Use math and exponential growth to your advantage. Since you said “about 3000”, I will take you at your word, and assume that 3375 = 15³ is a reasonable approximation of 3000.

                1. Macro > Start Recording
                2. FIND = \$, REPLACE = ¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶, ☑ Wrap Around, SEARCH MODE = regular expression, REPLACE ALL
                  • this will replace every dollar sign with 15 pilcrows
                3. FIND = ¶, REPLACE = ¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶, ☑ Wrap Around, SEARCH MODE = regular expression, REPLACE ALL
                  • this will replace every pilcrow with 15 pilcrows: so now we’re up to 15²=225 ¶ for every original $
                4. FIND = ¶, REPLACE = ¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶, ☑ Wrap Around, SEARCH MODE = regular expression, REPLACE ALL
                  • this will replace every pilcrow with 15 pilcrows: so now we’re up to 15³=3375 ¶ for every original $
                5. FIND = ¶, REPLACE = \r\n (I assume you want windows line ending, and either misunderstood \n or mistyped when you wrote \n\n originally; if I am wrong, use \n as your replacement instead), ☑ Wrap Around, SEARCH MODE = regular expression, REPLACE ALL
                  • this will replace each of the 3375 ¶ into a newline sequence
                  • so, in the end, you have 3375 newlines for each $ in your original
                6. Macro > Stop Recording
                7. Macro > Save Current Recorded Macro

                Playing back this macro will replace every $ with 3375 newline sequences.

                If you want exactly 3000, you can break it up differently: for example, do 20 in the first replacement, 15 in the second, and 10 in the third. This is when middle-school “factor these numbers” will help you in real life (your math teacher was right after all).

                ----
                On re-reading, maybe you wanted every EOL to be converted into “about 3000”. In which case, step two should search for $ instead of \$. Sorry if I misunderstood.

                B MRB 1 Reply Last reply Reply Quote 3
                • B MRB
                  B MR @PeterJones
                  last edited by B MR

                  @PeterJones
                  it worked, thanks!

                  alan, i understood what you clarify but i didn’t find what to copy in the xml file

                          <Macro name="newline" Ctrl="no" Alt="no" Shift="no" Key="0">
                              <Action type="0" message="2451" wParam="0" lParam="0" sParam="" />
                              <Action type="1" message="2170" wParam="0" lParam="0" sParam="&#x000A;" />
                          </Macro>
                  
                  Alan KilbornA 1 Reply Last reply Reply Quote 0
                  • Alan KilbornA
                    Alan Kilborn @B MR
                    last edited by Alan Kilborn

                    @B-MR said in how to add more then 1024 new lines at once?:

                    i didn’t find what to copy in the xml file

                    What you can do is go to this line:

                    <Action type="1" message="2170" wParam="0" lParam="0" sParam="&#x000A;" />

                    and select the &#x000A; part. Then hold down Ctrl+d for a bit to duplicate that part many times. Then select the whole line and do an in-selection Count (see Find tab of Find window) on 000A. That will tell you how many lines would get inserted when the macro runs. If you don’t have enough, copy and paste some more copies of &#x000A; until you have what you want.

                    Obviously borrowing (somewhat) from the Peter technique, if the Count reports that you have 500, copying what you have and pasting five times would get you to 3000. Use the Count function when you think you are done just to be sure you’re accurate.

                    1 Reply Last reply Reply Quote 0
                    • guy038G
                      guy038
                      last edited by guy038

                      Hello @b-mr, @peterjones, @alan-kilborn and All,

                      @b-mr :

                      So, folowing the @peterjones’s idea, as 3,000 = 20 × 15 × 10, here is the way to insert exactly 3,000 line-breaks, with a macro :


                      • If you’re using Windows files with the indication Windows (CR LF) in the status bar, insert the following macro in the <Macros> node of your active shortcut.xml file :
                              <Macro name="Insert and Select 3,000 WINDOWS Line-Breaks" Ctrl="no" Alt="no" Shift="no" Key="0">
                      
                                  <Action type="1" message="2170" wParam="0" lParam="0" sParam="&#x000D;" />
                                  <Action type="1" message="2170" wParam="0" lParam="0" sParam="&#x000A;" />
                                  <Action type="0" message="2303" wParam="0" lParam="0" sParam="" />
                      
                                  <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
                                  <Action type="3" message="1601" wParam="0" lParam="0" sParam="(?s).+" />
                                  <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
                                  <Action type="3" message="1602" wParam="0" lParam="0" sParam="$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0" />
                                  <Action type="3" message="1702" wParam="0" lParam="640" sParam="" />
                                  <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
                      
                                  <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
                                  <Action type="3" message="1601" wParam="0" lParam="0" sParam="(?s).+" />
                                  <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
                                  <Action type="3" message="1602" wParam="0" lParam="0" sParam="$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0" />
                                  <Action type="3" message="1702" wParam="0" lParam="640" sParam="" />
                                  <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
                      
                                  <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
                                  <Action type="3" message="1601" wParam="0" lParam="0" sParam="(?s).+" />
                                  <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
                                  <Action type="3" message="1602" wParam="0" lParam="0" sParam="$0$0$0$0$0$0$0$0$0$0" />
                                  <Action type="3" message="1702" wParam="0" lParam="640" sParam="" />
                                  <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
                              </Macro>
                      

                      • If you’re using Unix files, with the indication Unix (LF) in the status bar, insert the following macro in the <Macros> node of your active shortcut.xml file :
                              <Macro name="Insert and Select 3,000 UNIX Line-Breaks" Ctrl="no" Alt="no" Shift="no" Key="0">
                      
                                  <Action type="1" message="2170" wParam="0" lParam="0" sParam="&#x000A;" />
                                  <Action type="0" message="2303" wParam="0" lParam="0" sParam="" />
                      
                                  <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
                                  <Action type="3" message="1601" wParam="0" lParam="0" sParam="(?s).+" />
                                  <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
                                  <Action type="3" message="1602" wParam="0" lParam="0" sParam="$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0" />
                                  <Action type="3" message="1702" wParam="0" lParam="640" sParam="" />
                                  <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
                      
                                  <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
                                  <Action type="3" message="1601" wParam="0" lParam="0" sParam="(?s).+" />
                                  <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
                                  <Action type="3" message="1602" wParam="0" lParam="0" sParam="$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0" />
                                  <Action type="3" message="1702" wParam="0" lParam="640" sParam="" />
                                  <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
                      
                                  <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
                                  <Action type="3" message="1601" wParam="0" lParam="0" sParam="(?s).+" />
                                  <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
                                  <Action type="3" message="1602" wParam="0" lParam="0" sParam="$0$0$0$0$0$0$0$0$0$0" />
                                  <Action type="3" message="1702" wParam="0" lParam="640" sParam="" />
                                  <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
                              </Macro>
                      

                      Best Regards,

                      guy038

                      1 Reply Last reply Reply Quote 0
                      • Neil SchipperN
                        Neil Schipper
                        last edited by Neil Schipper

                        Solution #4, or is it #5?

                        New file

                        Keeping your eye on line number in the middle of the status bar (or left margin if you enabled line num display in Prefs… Margins…), hold down ENTER until you reach line 101. Takes about 5 seconds. If you overshoot, hit backspace a few times.

                        Blinking cursor is now at line 101.
                        ctl-a to Select all
                        ctl-c to Copy to clip

                        cursor down once (originally omitted, added with an edit)

                        hold down ctl-v to paste repeatedly until line num is 3001. If you overshoot, hit ctl-z a few times.

                        Whole job takes about 15 seconds.

                        (edit: and 50*60 or 60*50 would be even faster)

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

                          @Neil-Schipper

                          I think the OP was truly looking for a “one step” solution, and you neglected stating recording a macro as part of your instructions. So I tried your instructions while macro-recording, and yes, indeed, they worked when playing back – sometimes things don’t always work when recording, but this time they did!

                          B MRB 1 Reply Last reply Reply Quote 2
                          • B MRB
                            B MR @Alan Kilborn
                            last edited by

                            @Alan-Kilborn
                            sorry for the late response,

                                    <Macro name="new" Ctrl="no" Alt="no" Shift="no" Key="0">
                                        <Action type="0" message="2451" wParam="0" lParam="0" sParam="" />
                                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="&#x000A;&#x000A;&#x000A;&#x000A;&#x000A;&#x000A;&#x000A;&#x000A;&#x000A;&#x000A;&#x000A;&#x000A;&#x000A;&#x000A;" />
                                    </Macro>
                            

                            i try a few copies first… it only add 3 lines…

                            guy038
                            didn’t work for me

                            neil
                            i need it to apply on 300 lines, and it’s not practical to do it manually

                            and also… correct me if i’m wrong, but did all the macros above apply to one line only?
                            i need it to apply in all the line in the file

                            thanks for bearing with me

                            PeterJonesP Alan KilbornA Neil SchipperN 3 Replies Last reply Reply Quote 0
                            • PeterJonesP
                              PeterJones @B MR
                              last edited by

                              @B-MR said in how to add more then 1024 new lines at once?:

                              all the macros above apply to one line only

                              Well, not “all”, as mine did every line, ad you said it worked for you.

                              Think of the others as learning exercises, and see if you can extend them to work on all lines. (For example, down-arrow cursor movements can be recorded, so if you add that to a single-line macro, and then run that macro N times, where N is the number of lines in your file, then it should work. But get creative, and see if you can find alternatives)

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

                                @B-MR said in how to add more then 1024 new lines at once?:

                                i try a few copies first… it only add 3 lines…

                                Hmm, I tried it and it added the correct number of lines…

                                1 Reply Last reply Reply Quote 0
                                • Neil SchipperN
                                  Neil Schipper @B MR
                                  last edited by Neil Schipper

                                  @B-MR said in how to add more then 1024 new lines at once?:

                                  it’s not practical to do it manually

                                  After you create the 3k empty lines in a new file, something you do once, you have all kinds of freedom.

                                  You can Select All, Copy, then change tabs to your working file, and paste the 3k lines anywhere you want.

                                  You can create a macro that does all kinds of things, including a pasting action. If clipboard is preloaded with the 3k lines, and the macro does not disturb the clipboard, there are many possibilities, including Find operations combined with paste operations, and, running the macro repeatedly as per Alan’s first post.

                                  You can save the 3k lines file to 3kLines.txt (etc) and have it on hand for reuse if this insertion process you are now attempting is something you expect to be doing often.

                                  It’s possible I (we?) don’t really understand your need. You have said very little about the file you are starting with, and what it should look like after the process.

                                  (Edit: oops, I repeated stuff Peter already said. And I agree with him that you need to show some creativity now that you have all these building blocks.)

                                  B MRB 1 Reply Last reply Reply Quote 1
                                  • B MRB
                                    B MR @Neil Schipper
                                    last edited by B MR

                                    everybody…
                                    i trust everything you said and tried is right…
                                    don’t know why it doesn’t working for me,
                                    anyway…
                                    for the meantime i’ll stick with peter solution

                                    thank you all!

                                    1 Reply Last reply Reply Quote 0
                                    • guy038G
                                      guy038
                                      last edited by guy038

                                      Hi, @b-mr,

                                      You said :

                                      guy038
                                      didn’t work for me

                                      So, I re-tried my macro and it worked as expected : it correctly inserted 3,000 empty lines, containing only the two chars \r\n !

                                      Don’t know why it didn’t work on your configuration ? Probably, you did not insert the macro within the right shortcuts.xml file !

                                      Best REgards,

                                      guy038

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

                                        @guy038

                                        Your macro inserts 3000 newlines, plus maybe some other stuff (depending on where the cursor is) from one original line. (We’ll come back to that.)

                                        But, as the poster said in one of the replies,

                                        i need it to apply on 300 lines

                                        Your macro only inserts the characters once. (Even before this, the original question involved searching for $, which is the end of each line in the file. That’s why I made my original solution do the replacement for every newline in the file – well, really, my original was for every literal dollar-sign, because I wasn’t thinking straight… but I corrected that in my postscript.)

                                        So the OP would have to manually run your macro 300 times to add 3000 newlines after each of the 300 lines in the file. My macro converts every newline in the file to ~3000 newlines in one run.

                                        I said in this post,

                                        plus maybe some other stuff … (We’ll come back to that.)

                                        Start with the file

                                        one
                                        

                                        Put the cursor between the o and the n and run your macro: there are 3000 lines of o followed by ne

                                        Undo. Put the cursor after the e. Run your macro. There are now 3000 lines of one followed by one blank line (if there was already a newline after the one)

                                        Undo. Put the cursor before the o. This is the only position that makes 3000 empty lines. But it puts the empty lines before one. The original statement, by regex searching for $, originally implied that the desire was to make this change at the end of the line, not the beginning.

                                        And, as I said earlier, the desire was for every EOL in the file to become 3000 newlines instead, which yours does not do in a single run.

                                        And as I said to @B-MR , if you added a “down arrow” to the end of the macro (<Action type="0" message="2300" wParam="0" lParam="0" sParam="" />), saved the shortcuts file, restart notepad++: now given the file

                                        one
                                        two
                                        three
                                        

                                        If you put the cursor before the t of two, and use Macro > Run a Macro Multiple Times, choose the Insert and Select 3,000 WINDOWS Line-Breaks from the pulldown list, and then choose Run until the end of the file
                                        4ad0cc2c-e532-440a-a8af-1cfa15814b91-image.png

                                        If you do that, then the end result will be one followed by 3000 blank lines, then two followed by 3000 blank lines, then three followed by 3000 blank lines.

                                        1 Reply Last reply Reply Quote 1
                                        • Paul WormerP
                                          Paul Wormer
                                          last edited by

                                          @PeterJones Maybe the following is a useful clarifying remark to your solution. Because I did not know the word “pilcrow”, I googled it and found that it is the technical term for “paragraph sign” (¶). I presume that more non-native speakers of English besides myself don’t know it. One can enter the symbol by hitting alt-20 (2 and 0 on the numeric keypad while keeping alt pressed).

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

                                            @Paul-Wormer said in how to add more then 1024 new lines at once?:

                                            Maybe the following is a useful clarifying remark to your solution. Because I did not know the word “pilcrow”…

                                            I don’t know that knowing the definition of the word is all that clarifying in regards to inserting a given number of blank lines.

                                            Perhaps more clarifying would be knowing why Peter used the pilcrow character in the first place. He did this because he wanted to use a character that is unlikely to be an existing character in a user’s document. This is so the replacement operations don’t accidentally hit characters that aren’t part of the solution proposed.

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