I Want to Automatically Choose Specific Text After Pasting the Clipboard

I want to paste the contents of the clipboard automatically select the specific text inside how to do, for example, I copy a text "abcdef" , I want to paste automatically select the "a" how to do it, sorry I am new, do not know how to operate. Thanks for your help!

@jone_smith -

Welcome to the forum. If you have Keyboard Maestro 10, the developer introduced a simple way to perform this.

  1. Simply create a new macro (I called mine Paste by Name due to the action but you can call your Paste Clipboard Contents or another name if you'd like).

  2. You can select the Paste by Name action by pressing Command-K or importing the Paste by Name action attached.

  3. Create a trigger (You see from the screenshot below I use Shift F19 or control-option-command-P)

And you are done.

Go to your Paste area (document, webpage etc.), type the trigger and you can use the arrow keys to select and enter your content or you can select the first letter and it will search. Press return and your selection will paste.

Paste by Name.kmactions (598 Bytes)

Try it out and let us know if you have any other questions.


Thank you for your reply, I want to paste it, and then some of the text inside is selected, like the picture below. So I can just edit it, instead of manually selecting "A".I tried your method and it pops up the checkbox, which is not what I need.

@jone_smith ,

I don't think I have enough information to help you or even use my comprehension to guess, at this point. What is the program referenced above? Can you create a video of what you are trying to do?

I've actually made one myself, but it's a bit more complicated, and less stable, by selecting the letter "A" after auto-pasting.
Screen Recording 2021-11-15 at 22.17.21 - 01

I thought you meant the system clipboard. From my view, this looks like a simple text expansion. Can you show the contents of your named clipboard that you are pasting from? And what application is that?

It is a simple text, and then the text is automatically selected after pasting it, for example, I paste "abcdef" and then automatically select the letter "a".Any program will do, not necessarily the one in my video.

Screen Recording 2021-11-15 at 23.56.47

I re-recorded another video, The clipboard contents are "a bcdef", and then automatically selected the letter "a" so I could change it directly in the Notes. My question is not to select the text by so many shortcuts, but to do it through built-in functions or code, because in some programs is not particularly stable.

Why use the clipboard?

Because my content has a certain format and it is used in a specific program, I just want to find a way to automatically select text through this simple example

I'm going out on a limb here and suggest you change the clipboard contents before you paste them into the app. This macro just illustrates this.

Test Prepend and Paste.kmmacros (2.9 KB)

KM 0 2021-11-15_16-28-40

If you need to remove the first character from the clipboard first, then that's easily done with an extra action after setting the variable to the clipboard contents...

Hey @tiffle ,

Let's try this. I'm trying to figure out the regex so that @jone_smith can just type iib and it KM would output b bcdef instead of the prompt solution. I just don't know the regex to pull and place the last character.

Here is my idea... (edited)
Test this.kmmacros (3.5 KB)

I can't remember how to do this. I'm sure it's possible.

Hi @kcwhat - to get the last character typed in the typed string trigger, you need to do this:
KM 0 2021-11-15_17-16-06

The KM variable Local__Trig will hold the last character.

Is that what you're after?

1 Like

@tiffle - As usual, you came through!

@jone_smith - This may get you closer... or not. But it solves the first part, I think. :slight_smile:

Test this.kmmacros (2.5 KB)

At least you can type your ii(any character from A to Z) and it will type your example.

Good luck.


1 Like

Hey Jone,

I don't think anyone has mentioned that Keyboard Maestro can reposition the cursor after inserting text by pasting.

Using that you can do something very simple as in my macro, or you can do some calculations and get pretty sophisticated.


Paste and Select v1.00.kmmacros (6.4 KB)
Keyboard Maestro Export

1 Like

Thank you all for your replies, it gives me a lot of ideas, as a newbie, there is still a lot to study, after I test it, then I will respond to you all.

1 Like

The above methods are not particularly effective, because the formatting will be lost, perhaps for plain text will be particularly effective, but I need to have formatted text, executed in a specific software

The method works, but for plain text, I have to save the format, and I don't know why it doesn't work as expected in certain software.My software is remnote, a note taking software, and there is no way to save the format and no way to get the cursor to the intended location.

Screen Recording 2021-11-17 at 20.10.20

I found the problem, almost all methods do not save the format, if it is plain text it may be better. The software I use is remote, a note taking software.

Thanks for your help, it seems to work only for plain text, I have done other settings and still can't save the format.