Need to automate stripping text formatting and blank lines from copied text

I have a web-based calculator that I regularly use to calculate information that I copy and paste into another application. I have a Keyboard Maestro script (that I copied from David Sparks) that pastes the text stripped of all formatting into its final location. the copied text is double spaced but I would like to paste it as single-line spaced text. See the example below of the original double spacing. I am looking for a simple solution to remove the space between each line that I can combine with format stripping. I don’t see an easy action in Keyboard Maestro. Happy to combine any automation or script modality to make it work. Any suggestions would be appreciated.

Example of current output pasted below:

Date of Surgery: 04-01-2010

Time Since Surgery: 12 years, 10 months

Months to Nadir Weight: 12

Time Since Nadir Weight: 11 years, 10 months

Pre-Operative

Preop Weight: 285 lbs | 129.3 Kg

KB has several tokens you should be able to search for. Try using the Search and Replace action to look for %LINEFEED%%LINEFEED% and then replace it with a single %LINEFEED%.

https://wiki.keyboardmaestro.com/token/LineFeed

Thanks Ill give it a try

Does it have to be done with Keyboard Maestro? I use an action in Drafts which strips out blank lines with a double click on the Mac or a single tap on the action in iOS

Or There is BBEdit which has a tool to remove blank lines just as easy in the search and replace.

That search and Replace with %LineFeed%%LineFeed% and replace with %LineFeed% in Keyboard Maestro does work though.

I was able to do it with Shortcuts also

1 Like