Community
    • Login

    HELP HOW TO INSERT text into blank lines with macro

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    9 Posts 3 Posters 535 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.
    • Steve TrevellaS
      Steve Trevella
      last edited by

      i am trying to create a macro to replace lines in 2 different g codes.
      i am almost there.
      my last problem is. i have a line that i need to insert a blank space below it and add text into it.
      i can find the line by finding letters in it.
      i can create a blank line under it, but i cant find a way to add text to that line.
      this needs to be all doable in macro as there is a few times it needs to repeat the process.
      is there a way to insert txt into blank lines under macro?
      or better
      as in find and replace, is there a way to do find text then add a blank below and add text to it.
      your knowledge would be very much appreciated

      Terry RT 1 Reply Last reply Reply Quote 0
      • Terry RT
        Terry R @Steve Trevella
        last edited by Terry R

        @Steve-Trevella said in HELP HOW TO INSERT text into blank lines with macro:

        your knowledge would be very much appreciated

        I would be doing what you require using a regular expression (regex). You seem to already be familiar with the Replace function.

        So a suitable regex for your situation would be:
        Find What:(?-s)(text i want to find.?)
        Replace With:${1}\r\ntext I want to insert
        Search mode is regular expression.

        So this finds the text you are looking for (obviously you need to replace the text I’ve used with your look for and inserted text) and continues to capture to the end of line (excluding the line feed/cariage return). The replace portion inserts a new line feed/carriage return, then the new text. The original line feed/carriage return is still there and now appends the new line inserted.

        And as you refer to a macro, which is just the keystrokes recorded of the replace function with the fields as described above.

        If this doesn’t suit you might have to provide an example as some of what you say isn’t entirely clear.

        Terry

        Steve TrevellaS 1 Reply Last reply Reply Quote 1
        • Steve TrevellaS
          Steve Trevella @Terry R
          last edited by

          @Terry-R thanks for your reply.
          i have a line. for example
          g0 x26 y68
          g1 x45 y67
          i want to add M10
          between those 2 lines
          this needs to happen a few times
          the only common character is g0,
          with the find i worked out with each g0 i can create a empty line below it
          but can not see how to add m10 to that space line using the macro.
          there may be 20 to 50 times in each file so macro is the way i need to do it.
          i am not familiar with the stuff… i have managed to work out how to find and replace all the other lines that need to change… but this has me stumped??

          Terry RT Alan KilbornA 2 Replies Last reply Reply Quote 0
          • Terry RT
            Terry R @Steve Trevella
            last edited by Terry R

            @Steve-Trevella

            So did you try my solution? Just enter g0 in place of the “text I want to find” and the m10 in place of the “text I want to insert”. Don’t forget the search mode must be “regular expression”.

            Try it on a copy of the file and find next, then replace buttons just so you can see what is happening.

            Terry

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

              @Steve-Trevella

              I’d try:

              Find: (?-is)^g0.*(\R)
              Replace: $0M0$1
              Search mode: Regular expression

              Also, you can’t just say M10 one place in what you want, and m10 in another – this just shows us that you can’t pay close attention to detail, and makes it harder to help you. :-(

              Steve TrevellaS 2 Replies Last reply Reply Quote 1
              • Steve TrevellaS
                Steve Trevella @Alan Kilborn
                last edited by

                @Alan-Kilborn
                983ddc1a-0fd4-42ba-ad82-ec63cafb60ce-image.png

                Terry RT 1 Reply Last reply Reply Quote 0
                • Terry RT
                  Terry R @Steve Trevella
                  last edited by

                  @Steve-Trevella
                  You aren’t reading the solutions at all. Search mode is “regular expression” not “normal”!

                  Also you could remove the tick boxes on match whole words and match case.

                  Terry

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

                    You aren’t reading the solutions at all.

                    This is true.
                    And the attention-to-detail aspect is getting worse, not better. :-(
                    We can’t help those that won’t help themselves.

                    Notes:

                    • g0 suddenly somehow became G00
                    • no one said to use \r in the Replace without a \n following
                    • it sure looks like there is a space between (?-s) and G00 in the Find
                    1 Reply Last reply Reply Quote 2
                    • Steve TrevellaS
                      Steve Trevella @Alan Kilborn
                      last edited by

                      @Alan-Kilborn said in HELP HOW TO INSERT text into blank lines with macro:

                      $0M50

                      HI THANKYOU.
                      I CAN MAKE THAT WORK!!
                      MUCH APPRECIATED

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