Reading all the comments I can see that my macro could be improved substantial.
But I have to say that I use it mostly for repeating up to 20 items.
And it is normally one character.
Here I do not experience any performance issues.
I can also imagine that seeing a solution using simple and native KM actions could be helpfull for people learning to use KM.
But still thanks for all the optimization tips. They are helpful.
Thank you for your reply.
I am curious to ask : in what context would you want to repeat text multiple times?
I apologize for my badly formulated question: I was proposing a solution (repeat underscore) instead of asking a clear question (I want to draw a line in pages).
it’s all my fault for not asking the question properly. My question should have been flagged as ‘inappropriate’ and below the IQ level of forum members !
I have an interesting variation of this where I need N left arrows. I can't think of any way other than to Type a Character inside of a repeat statement. It's awfully tedious to watch when the repetition gets up towards 50 or 100 times. Is there a better way to get N characters that move the cursor but don't type any "real" characters?
I need N left and right arrows in the context of text editing in any application where you can edit text. That’s basically it.
Specifically, after copying the selection, replacing it with some other stuff, and pasting the former selection back, I want to reselect not just the former selection, but the characters I added. Since few applications provide a way to work with the selection, and those that do don’t make it easy, and in any case use different mechanisms from each other, I am left having to do this in a general way. I know how many characters there are in the copied selection, and I know how many characters I have added and where I added them. Thus, I can use a series of right and left arrows (some with shift down) to select the new text along with the old. But it is slow and strange.
No, I don’t know if these are characters, words, lines, paragraphs, or pages, or even which of these the application knows how to deal with.
Other than extensively AppleScriptable apps, I think you’re out of luck. Only individual arrow keys will have any chance of working reliably (no two applications define a “word” in the same way (except by random good luck), so Option-arrow keys wont work).
If you just want to move the cursor, you could do something like:
Set Find Pasteboard to “H3R3” (unique code)
Insert text “H3R3”
Paste One thing
Paste Another thing
Type Keystroke: Command-Shift-G
Type Keystroke: Delete
But you want to select, and there isn’t any way to “extend selection to Find location” (unfortunately!).