Cut and Paste

This is a variant on my Select All and Copy macro.

What the macro does

Very simple: When you press ⌘X and hold down the X slightly longer it will cut the selection and paste the previous clipboard content in place.

(Think of ⌘X as eXchange.)

Trivial Example

You want to replace paragraph A in section 1 with a paragraph B from section 2, and paste paragraph A in place of paragraph B in section 2.

Normally you would…

  1. ⌘X paragraph A in section 1.
  2. Go to section 2 and ⌘V paragraph A after/before paragraph B.
  3. ⌘X paragraph B.
  4. Go to section 1 and ⌘V paragraph B.

With this macro…

  1. ⌘X paragraph A in section 1.
  2. Go to section 2 and long-press ⌘X paragraph B.
  3. Go to section 1 and ⌘V paragraph B.

Not really tremendous savings of work, but, since it comes with no drawbacks, why not use it?

Secondary Use (aka side-effect)

You can use the macro also as quick access to the past clipboard:

If you long-press ⌘X without having selected anything it will just paste the past clipboard #1. The current clipboard will be restored.

So you have the past clipboard always at your finger tips, without need to open the clipboard history. (Depending on the app where you’re in you have to live with the warning beep ;‌-)

Cut and Paste.kmmacros (4.4 KB)


Great idea, thank you for sharing.

It is quite sensitive though. If I hold it just a little bit longer, it will paste a lot of text.

Strange. Here it pastes just one time, even when I hold down ⌘X for five seconds.

Edit: Did you download the macro file or have you built the macro by yourself? It may have to do something with the timeout and/or abort settings of the actions.

I downloaded the macro from the link you provided.

I don’t know. I tested it on my MacBook and it behaves the same. But all my Macs are pretty slow, so maybe your Mac is too fast for my macro :wink:

You can try a couple of things:

  • Play with a longer timeout for the Cut action (currently it’s at 0.4s). Since a second macro run always will make the Cut action fail (because nothing is selected), this should lead to a longer runtime. (See screenshot.)
  • Set the timeout of the Cut action to abort the macro. (See screenshot.) However, with this you will lose the “Secondary Use” (pasting the past clipboard without cutting)
  • Try a Semaphore Lock at the beginning of the macro (I don’t see any different behavior with it, but it may be different on your machine.)

But since the macro trigger is a key press (not a key down), I don’t really understand right now why it does multiple pastes for you.


Another option: try it with a pause at the end of the macro. (for example 1s)

Actually one thing that I started doing inspired by your macros is have all of my keys have two functionalities, one on short press and one on long. I can achieve this with karabiner and this xml for it.

I really do recommend it, it works wonders. :smiley:

Somehow Karabiner is not made for me. I installed it every year or two and always it managed to mess up my Mac.

Last time it slowed down typing and window scrolling to a unusable rate, within 30 minutes after system boot.

Now I’ve given up all efforts with Karabiner. And not really missing it. (Well, the pseudo Vi mode was a nice gimmick, and some clever tricks with the shift keys…)