Community
    • Login

    How can I insert a new line between 2 specific duplicate lines in the sequence?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 3 Posters 164 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.
    • clayman648C
      clayman648
      last edited by

      I want to insert a new line, {Delay 0.05} between every 2 specific duplicate lines like
      Before:
      {LMouse up
      {LMouse down

      After:
      {LMouse up
      {Delay 0.05}
      {LMouse down

      Example: (The numbers on the end change
      {Delay 0.14}
      {Move (940,166)}
      {Delay 0.05}
      {LMouse down (940,166)}
      {Delay 0.05}
      {LMouse up (940,166)}
      {Delay 0.05}
      {LMouse down (940,166)}
      {LMouse up (940,166)}
      {Delay 0.05}
      {LMouse down (940,166)}
      {Delay 0.05}
      {LMouse up (940,166)}
      {LMouse down (940,166)}
      {LMouse up (941,172)}
      {LMouse down (941,172)}
      {Delay 0.05}
      {LMouse up (941,172)}
      {Delay 0.05}
      {LMouse down (941,172)}
      {Delay 0.05}
      {LMouse up (941,172)}
      {LMouse down (941,172)}
      {Delay 0.05}
      {LMouse up (941,172)}
      {LMouse down (941,172)}

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

        @clayman648 said in How can I insert a new line between 2 specific duplicate lines in the sequence?:

        I want to insert a new line, {Delay 0.05} between every 2 specific duplicate lines like

        What you ask is certainly possible. There is an issue with your example though. It doesn’t appear to be consistent with your request. In one area you have a up, then down, then up and down. Only then do you have the delay. Later you have the up and down set without a delay between them. I’m assuming you just weren’t that good at providing an accurate “after” example, that is if the long example is supposed to show an after look.

        So using the Replace function you need to have the search mode set to “regular expression”. Then we have:
        Find What:(?-s)^({lmouse up.*)(\R)({lmouse down.*)
        Replace With:\1\2{Delay 0.05}\2\3

        You can click on either “Replace” (which means you singularly click for each replacement) or “Replace All” which will change all the sets.

        Have a check of your example and if you now believe there is more to the request then tell us. Otherwise attempt my solution (above) and check your result.

        Terry

        clayman648C 1 Reply Last reply Reply Quote 3
        • clayman648C
          clayman648 @Terry R
          last edited by

          @Terry-R

          Oh my god, thank you so much Terry!

          in future, could I just change {lmouse up and {lmouse down to do the same thing? or is it different if the starting character isn’t special?

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

            @clayman648

            Not sure exactly what you mean. However if you are just changing the alphabetic characters, then yes, other words would also work.

            There are some special characters recognised by regular expressions, { and } can be depending on context. in this case the escape character wasn’t needed.

            Our FAQ posts have references to the regular expressions system, so if you want to learn more, start there.

            Terry

            dr ramaanandD 1 Reply Last reply Reply Quote 0
            • dr ramaanandD
              dr ramaanand @Terry R
              last edited by

              @Terry-R Using {Delay 0.05}\2\1\2\3 in the Replace field will be more accurate

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