• Login
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 175 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.
  • C
    clayman648
    last edited by Jan 13, 2025, 1:56 AM

    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)}

    T 1 Reply Last reply Jan 13, 2025, 2:14 AM Reply Quote 0
    • T
      Terry R @clayman648
      last edited by Terry R Jan 13, 2025, 2:15 AM Jan 13, 2025, 2:14 AM

      @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

      C 1 Reply Last reply Jan 13, 2025, 2:38 AM Reply Quote 3
      • C
        clayman648 @Terry R
        last edited by Jan 13, 2025, 2:38 AM

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

        T 1 Reply Last reply Jan 13, 2025, 2:45 AM Reply Quote 0
        • T
          Terry R @clayman648
          last edited by Jan 13, 2025, 2:45 AM

          @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

          D 1 Reply Last reply Jan 13, 2025, 1:02 PM Reply Quote 0
          • D
            dr ramaanand @Terry R
            last edited by Jan 13, 2025, 1:02 PM

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