• Login
Community
  • Login

HELP HOW TO INSERT text into blank lines with macro

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
9 Posts 3 Posters 555 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.
  • S
    Steve Trevella
    last edited by May 9, 2024, 6:21 PM

    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

    T 1 Reply Last reply May 9, 2024, 7:11 PM Reply Quote 0
    • T
      Terry R @Steve Trevella
      last edited by Terry R May 9, 2024, 7:12 PM May 9, 2024, 7:11 PM

      @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

      S 1 Reply Last reply May 9, 2024, 8:00 PM Reply Quote 1
      • S
        Steve Trevella @Terry R
        last edited by May 9, 2024, 8:00 PM

        @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??

        T A 2 Replies Last reply May 9, 2024, 8:15 PM Reply Quote 0
        • T
          Terry R @Steve Trevella
          last edited by Terry R May 9, 2024, 8:19 PM May 9, 2024, 8:15 PM

          @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
          • A
            Alan Kilborn @Steve Trevella
            last edited by Alan Kilborn May 9, 2024, 8:18 PM May 9, 2024, 8:17 PM

            @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. :-(

            S 2 Replies Last reply May 9, 2024, 8:19 PM Reply Quote 1
            • S
              Steve Trevella @Alan Kilborn
              last edited by May 9, 2024, 8:19 PM

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

              T 1 Reply Last reply May 9, 2024, 8:21 PM Reply Quote 0
              • T
                Terry R @Steve Trevella
                last edited by May 9, 2024, 8:21 PM

                @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

                A 1 Reply Last reply May 9, 2024, 8:23 PM Reply Quote 1
                • A
                  Alan Kilborn @Terry R
                  last edited by Alan Kilborn May 9, 2024, 8:29 PM May 9, 2024, 8:23 PM

                  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
                  • S
                    Steve Trevella @Alan Kilborn
                    last edited by May 9, 2024, 8:29 PM

                    @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
                    7 out of 9
                    • First post
                      7/9
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors