Copy and paste inside a macro
-
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)
- edit a bunch of text
- Copy what is left of the line to clipboard (this is what I am having issues with)
- type some text
- paste content of clipboard (from step 2) (also having issues with this)
- type some more text
- paste content of clipboard (from step 2) (also having issues with this)
- type some more text
- 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?
-
@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. -
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 5678I place the cursor directly after the number 4 and execute the macro, it will result in
1234 added_text 1234 another_text 1234 5678and cursor is in front of number 5.
@Gregory-West
if this is what you are looking for, then the following steps I did are- place the cursor to the position you want to have
- press SHIFT+POS1 (to select everything in the line left to the cursor)
- press CTRL+C (copy)
- press END (to move curosr to the end position of the line)
- add your additional text
- press CTRL+V (paste)
- repeat step 5 and 6 as often as you want
- press DOWN_ARROW (to jump into the next line)
- press POS1 (to jump to the first position of that line)
save it - done.
Cheers
Claudia -
@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.
-
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
$0syntax represents ALL the search contents ! -
To insert a new string, just do any other selection and update the Replace dialog, hitting the
Ctrl + Hshortcut ! -
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
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