"Insert Styled Text by Pasting" ... unwanted double spacing

I'm using "Insert Styled Text by Pasting" to paste text into an email (online version of gmail).

If I type the string "email1" within a new email, it will paste the following:

Dear XX,

Thank you for your email. We will respond to you shortly.

If you need immediate assistance, please call us at 1-800-888-8888.

Best Regards,

I will then copy the above from the email and paste it into a Google Sheet. After pasting into Google Sheet (or anywhere else), there will be 2 additional lines added after each line.

Is there any way to remove the additional lines? Thank you!

Can you please post your actual macro? In order to help, especially for something like this with text formatting, it's important that we can look at the actual commands and text in your macro.

To do so, select the macro, click the Share button, and click New Topic. This will create a new topic posting in the forums, with the macro embedded. Select all that text and copy (or cut) it to the clipboard, then close the new topic post.

Open a reply post in this thread, and paste the copied text.


Support Ticket - 3 - Last E-Mail - ZH Macro (v11.0.3)

Support Ticket - 3 - Last E-Mail - ZH.kmmacros (4.9 KB)

Keyboard Maestro Export

Many thanks, Rob!

Thanks. It appears that whatever is happening, it's happening when you go from Gmail to Google Sheets. I ran your macro in TextEdit, and it pasted this:


Hi xx,


:wavy_dash: 0910-926-295 (中文服務: Summer)
:wavy_dash: 0981-148-894 (English Support: Brent)



I then copied that and pasted it into another TextEdit window, and got the same thing back. I pasted it into BBEdit, and saw the same thing—and there aren't any hidden Returns, as seen by the invisible character markers:

I got the same thing pasting into Pages and Word, so it doesn't seem that there are double returns in what your macro creates. But somehow, copying that from Gmail into Sheets is giving you double line breaks. I don't use Google's products, so I can't test this, but it seems the macro is doing what it should be doing.


Thanks for the quick reply and help, Rob.

Perhaps it's an html formatting issue. Like you, whenever I paste into textedit or pages, it formats correctly. However, no matter where I paste it online, the hidden returns display.

I discovered a (not so ideal) workaround....paste into textedit, then copy and paste into Google Sheet, the formatting is correct.

Screen Shot 2024-07-03 at 05.32.25 AM
Screen Shot 2024-07-03 at 05.33.04 AM

I suppose one possibility, particularly if any of this originates on, or passes through, a Windows system, or some Microsoft application, is that it has lines delimited by:


(\r + \n)

and it may be worth experimenting with a Keyboard Maestro filter action, perhaps, for example:

or a regular expression split to lines, on a wider range of possibilities,

// lines :: String -> [String]
const lines = s =>
    // A list of strings derived from a single string
    // which is delimited by \n or by \r\n or \r.
    0 < s.length
        ? s.split(/\r\n|\n|\r/u)
        : [];

followed by normalisation with a linefeed join:

// unlines :: [String] -> String
const unlines = xs =>
    // A single string formed by the intercalation
    // of a list of strings with the newline character.

Thanks for your help, ComplexPoint! I'm using a Mac, and I was unable to find the Filter Variable action in my KM (latest version 11.0.3).

  1. In the ⌘^A action search dialog, type filter
  2. Look for, e.g. 'Filter System Clipboard With Capitalize'

  1. adjust the three options using the double-chevron drop-down menus

e.g. to:

Got it, thanks. Unfortunately that didn't resolve the issue.