• Login
Community
  • Login

Copy and paste inside a macro

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 4 Posters 7.1k 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.
  • G
    Gregory West
    last edited by Jul 6, 2017, 5:45 PM

    I need to create a macro, what I thought would be very simple… So far I have not figured it out yet. Here is what the macro needs to do on each line (and there are 100’s of them)

    1. edit a bunch of text
    2. Copy what is left of the line to clipboard (this is what I am having issues with)
    3. type some text
    4. paste content of clipboard (from step 2) (also having issues with this)
    5. type some more text
    6. paste content of clipboard (from step 2) (also having issues with this)
    7. type some more text
    8. go to the beginning of next line.

    It is the copy and paste part I can not figure out for the life of me. Any one have an idea what keystrokes/commands I need to use?

    1 Reply Last reply Reply Quote 0
    • J
      Jim Dailey
      last edited by Jul 6, 2017, 7:14 PM

      @Gregory-West
      My recollection is that macros do not support copy and paste. I don’t think you can do what you want using macros.

      C 1 Reply Last reply Jul 6, 2017, 8:55 PM Reply Quote 0
      • C
        Claudia Frank @Jim Dailey
        last edited by Jul 6, 2017, 8:55 PM

        @Jim-Dailey

        Hi Jim, looks like it isn’t the case anymore or I didn’t understand the question correctly.

            <Macro name="copy_paste_macro" Ctrl="no" Alt="no" Shift="no" Key="0">
                <Action type="0" message="2454" wParam="0" lParam="0" sParam="" />
                <Action type="0" message="2178" wParam="0" lParam="0" sParam="" />
                <Action type="0" message="2451" wParam="0" lParam="0" sParam="" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam=" " />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="a" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="d" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="d" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="e" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="d" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="_" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="t" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="e" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="x" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="t" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam=" " />
                <Action type="0" message="2179" wParam="0" lParam="0" sParam="" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam=" " />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="a" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="n" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="o" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="t" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="h" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="e" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="r" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="_" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="t" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="e" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="x" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="t" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam=" " />
                <Action type="0" message="2179" wParam="0" lParam="0" sParam="" />
                <Action type="0" message="2300" wParam="0" lParam="0" sParam="" />
                <Action type="0" message="2453" wParam="0" lParam="0" sParam="" />
            </Macro>
        

        let’s assume I have the text

        1234
        5678
        

        I place the cursor directly after the number 4 and execute the macro, it will result in

        1234 added_text 1234 another_text 1234
        5678
        

        and cursor is in front of number 5.

        @Gregory-West
        if this is what you are looking for, then the following steps I did are

        1. place the cursor to the position you want to have
        2. press SHIFT+POS1 (to select everything in the line left to the cursor)
        3. press CTRL+C (copy)
        4. press END (to move curosr to the end position of the line)
        5. add your additional text
        6. press CTRL+V (paste)
        7. repeat step 5 and 6 as often as you want
        8. press DOWN_ARROW (to jump into the next line)
        9. press POS1 (to jump to the first position of that line)

        save it - done.

        Cheers
        Claudia

        1 Reply Last reply Reply Quote 1
        • J
          Jim Dailey
          last edited by Jul 6, 2017, 9:08 PM

          @Claudia-Frank Thanks for setting me straight. I have not tried this for a long, long time; it is nice to see it is being handled now.

          1 Reply Last reply Reply Quote 0
          • G
            guy038
            last edited by Jul 8, 2017, 9:06 PM

            Hello, @gregory-west,

            No doubt, @claudia-Frank, that your macro does the job, correctly !!

            But, I’m thinking about an easier method !

            • First, select any range of characters that is to be repeated, several times, with additional text

            ( In our example it would be all the characters, located to the left of a specific column ! )

            • Secondly, opens the Replace dialog ( Ctrl + H )

            => The selection is, automatically, filled up, in the Search what: box

            • In the Replace with: box, simply type $0 added text $0 another text $0

            • Select the Regular expression search mode ( IMPORTANT )

            • Click on the Replace button, several times or just once time the Replace All button

            Et voilà !

            Notes :

            • The $0 syntax represents ALL the search contents !

            • To insert a new string, just do any other selection and update the Replace dialog, hitting the Ctrl + H shortcut !

            • You may, as well, change the additional replacement text. For example : $0 This is $0 the text $0 to insert, among the "$0" strings

            Remark :

            Gregory, if your selection contains one, or more, of these 13 characters . [ { } ( ) \ * + ? ^ $ |, you’ll must escape each of them, with a backslash ( \ ), as there are special regex characters !

            Best Regards,

            guy038

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