Community
    • Login

    how to copy into multiple line into their orig line

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 1.6k Views 1 Watching
    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.
    • FujiyamaVolcanoF Offline
      FujiyamaVolcano
      last edited by

      I am trying to make a simple move script and it involve hundred of files
      how can I copy content into their original line
      Example
      1.txt
      2.txt
      3.txt
      into this
      1.txt 1.txt
      2.txt 2.txt
      3.txt 3.txt

      1 Reply Last reply Reply Quote -1
      • guy038G Offline
        guy038
        last edited by

        Hello, @fujiyamavolcano, and All,

        Very easily, indeed ! No need for a script language to achieve that simple task. Just use a regular expression search/replacement.

        • Open the Replace dialog

        • Type in (?-s)^.+ in the Find what: zone

        • Type in $0\x20$0 in the Replace with: zone

        • Select the wrap around ( or the In selection option if you restrict replacement to a previous selection )

        • Click on the Replace All option

        That regex replaces any text, of a line, with two copies of that text, separated by a space character, in the same line !

        So, from the initial text :

        This is
        a test
        12345
        1.txt
        2.txt
        3.txt
        *--*
        

        You obtain, after replacement,

        This is This is
        a test a test
        12345 12345
        1.txt 1.txt
        2.txt 2.txt
        3.txt 3.txt
        *--* *--*
        

        Notes :

        • The (?-s) modifier ensures that the special . character will match a single standard character, only, and not the End of Line characters

        • Then, the part .+ represents any non-empty range of standard characters , of each line, starting at beginning of line ( ^ )

        • In replacement, we rewrite the overall match ( $0 ), followed with a space character ( \x20 ), and, finally, followed again with the overall match ( $0 )

        Remarks :

        • In replacement, you may insert a simple space character ( or more, if necessary ) , instead of the \x20 syntax

        • You may, also, write multiple copies, of each initial line, in the same line. For instance, with the initial text, above, the regex S/R :

        SEARCH (?-s)^.+

        REPLACE Line repeated 3 times : | $0 | $0 | $0 |

        would product the following test :

        Line repeated 3 times : | This is | This is | This is |
        Line repeated 3 times : | a test | a test | a test |
        Line repeated 3 times : | 12345 | 12345 | 12345 |
        Line repeated 3 times : | 1.txt | 1.txt | 1.txt |
        Line repeated 3 times : | 2.txt | 2.txt | 2.txt |
        Line repeated 3 times : | 3.txt | 3.txt | 3.txt |
        Line repeated 3 times : | *--* | *--* | *--* |
        

        Best Regards,

        guy038

        FujiyamaVolcanoF 1 Reply Last reply Reply Quote 1
        • FujiyamaVolcanoF Offline
          FujiyamaVolcano @guy038
          last edited by

          @guy038 thanks
          you got upvoted

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors