Changing comma delimited list into paragraphed list

This is probably dead simple, but I am a total noob and have been searching for 2 hours to no avail.

I need to change this type of list:

0001, 0002, 0003, etc

into this:





in applescript or KBM itself.

thats literally all I need to do. please help

Not a problem. Try plugging these regular expressions into a "Search and Replace [Variable/Clipboard]" action (depending on what you're using to store this list):

Search: ,\s*

Replace: \n\n

The resulting action should look like this:


wow. I can’t believe something so simple took me 2 and half hours to find. thank you so much for your help.

Happy to help! Regular expressions can be maddeningly opaque until they click, but even simple ones like this can be very useful, in KBM and many other places.

really thank you so so much. as complicated as my macro is, this was the one thing I just couldn’t seem to find any simple documentation on, and the one thing leaving a gap between AppleScript and KBM. now that this works my whole macro can be finished, saving me countless hours of time and frustration

1 Like

What you might not have known is the newline (\n) character. That’s how you turn one line into two.

Generally, if you’ve hit a block and can’t get past it for more than 30-60 minutes, it’s time to post on the forum. Even if you continue and then find a solution, you can then post your own answer and help the next person.

Regular Expressions are a great tool, and a skill well worth learning, even though there is a definite learning curve involved. The time invested will likely be paid back many fold (it’s a bit like Keyboard Maestro itself really).

1 Like


There's no doubt about the payback of learning RegEx, but I have to say that learning Keyboard Maestro is far, far easier.

The combination of KM and RegEx is awesome!

See Regular Expressions (KM Wiki).


I've tried making this macro and the system clipboard is changed correctly with commas ommitted and new lines added.

I can't get the macro to actually paste the altered text to complete the action, (although I can paste manually right after.)

I've tried the action "insert text by pasting" and "paste" and "type a keystroke" with command V. None work.

Can anyone help?

Post your macro (instructions here) so people can take a look -- while it sounds like you're doing everything right, maybe you've a mis-set action option somewhere.

Are you using any other clipboard utilities, like Pastebot or similar? Always good to include a note of such if you're having Clipboard issues.

I fixed it. Apparently there needs to be a "pause" action before the simulated Command-V keystroke.

Generally it's better to use the Copy and Paste actions instead of simulating Cmd-C and Cmd-V – because they have built-in pauses and are designed to work in the Keyboard Maestro context.

It's all too easy to have timing issues with simulated keyboard commands.