Paste Without Formatting, But With Link

I frequently copy links from web pages to be pasted into emails I'm composing. However, I then need to update the email typeface to overwrite the font style of the link I just pasted in. Is it possible to use Keyboard Maestro to do the following?

  1. Clear the style from the current clipboard
  2. Restore the link, but none of the other type style
  3. Paste the clipboard

If there's a better way to go about this, please let me know. I'm still learning to conceptualize more advanced KM and AutoHotkey macros instead of resorting to the same few workflows over and over.

you can use Apply Style to System Clipboard:
then you can paste it and it'll use same font used in mail app.


This is a very cool way to do this. I hand't thought of this before. I tend to paste as plain text into Mail but using this method opens up other possibilities. Great.

This is great, but for some reason the output is just text, no link. What am I missing?

look here: Set Clipboard to RTF Hyperlink & Plain Text MD Link

dumb question if you paste a link and press Return, doesn't the text get converted to link automatically??

Yes - I think you’re right. Mail just recognises text which is a link and formats it as a hyperlink automatically so, there shouldn’t be any problem with keeping hyperlinks no matter how the text is copied and pasted.

I have noticed that sometimes you don’t see the hyperlink formatting until after the email is sent. If I check a sent email it always has the clickable hyperlink (in blue etc).

But I suppose this only applies to hyperlinks where the text is also specifically the address of the hyperlink. If the text is different to the actual address then the hyperlink would get lost as there is no way Mail can know what address the hyperlink bit of text was referring to.

1 Like

also you can always use Cmd-K

I should have clarified in my original email that the linked text I'm copying and pasting is not formatted like a URL, but rather as linked text. For example:

So with the above example, I'd like to:

  1. Copy "Google".
  2. Strip out all text styling, but not the associated link.
  3. Paste into an email with no associated typeface, but with the link.

Is that sort of thing possible? I recognize what I might be asking for is "plain text," but that "plain text" can't have an associated link by definition.

Nope, you can't do that because the hyperlink is actually formatted as Rich Text in apps like Mail. And, of course, Rich Text always has some style.
The best you can do is to change the style using the KM Apply Style to Clipboard action to get the style you want (to match what's in Mail).

You may be thinking of the HTML Anchor tag, which has no inheirent style unless set by CSS. Otherwise it generally takes on the font of the element where it is placed.

I have just tried out Hello's suggested solution and it seems to work perfectly for what you are after.

In my case my email default font is Helvetica 12pt. So, I set the action to format the clipboard that way and then paste (exactly like you have done).

The result is that a section of text copied from Safari pastes into Mail in Helvetica 12pt but keeps the link. The one thing I see I have done differently to you is check the boxes for "size" at 12pt and "foreground" as black.

Paste Without Formatting, But With Link.kmmacros (2.7 KB)

1 Like

Here the text from Safari pasted normally, without using the Macro:

And here using the Macro to paste:

1 Like

This is working for pasting from Safari into Mail, except for line-spacing: if the lines on a website have space between them, they'll be spaced out when pasted via this method. For example, this text from a forum post has spacing between the lines because of the margin styling (specifically, the margin-block-start and margin-block-end properties):

It looks like this when pasted into Mail with a macro that uses the "Apply Style to Clipboard" action, with the font set to 14 point Georgia:

And, in Mail, it is impossible to adjust line-spacing, so I'm stuck with it. You mention that Mail uses Rich Text for stying, and indeed, when I paste the above into TextEdit, the "Line and paragraph spacing" information looks like this:

Does anyone have an idea about how to address this? It would be great if the "Apply Style to Clipboard" action had options for line-spacing, but it doesn't seem to.

Hey Phil,

You realize @JMichaelTX will not be replying...

The Passing of JMichaelTX

JMichaelTX – Unforgettable Generosity With His Time and Knowledge

As for your problem – did you try removing styles from the clipboard?


See: Filter Action.


1 Like

Oh…. I'm sorry to learn that!

Thank you for stepping in to help! The trouble is, if you remove styles, you also remove the hyperlink, and the goal is to remove all the styling except hyperlinks. Or, rather—since that doesn't seem possible—the goal is to re-style the text to otherwise match the default style for message composition in one's Mail app.

The Apply Style to Clipboard action suggested earlier in the thread would address my scenario if it enabled line-spacing to be specified, but it doesn't seem to.

Two things:

  1. Try Paste Matching Style from Mail's Edit menu.
  2. Convert the RTF on the Clipboard to HTML.
    • Edit the HTML.
    • Put the HTML back on the Clipboard as RTF.

Adjusting RTF on the clipboard is not exactly simple. Personally I have no idea of how tough it would be to regulate or remove paragraph spacing, but that said it's a feature I wouldn't mind having myself. I regularly encounter text in which I want to keep the style but need to squash unwanted paragraph spacing.


You can manage this now, but it's a bit convoluted.

Here's how you get HTML from the RTF on the Clipboard:

Convert RTF on the Clipboard to HTML v1.00.kmmacros (5.4 KB)

I'd have to see a sample of your problem text to have an idea of how to massage the HTML to fix it. Upload a zipped RTF file if you want help with that.


No idea, sorry. “With Link” generally means it has to have formatting, so “Without Formatting, But With Link”, I don't know if that is possible.

You could try replacing spaces in a URL to its URL encoding %20

Would you be consider, in a future release, adding to the Apply Style to Clipboard action the ability to alter line-spacing and paragraph-spacing?

This would not meet the original request in the thread, but for quoting multiple lines from webpages in Mail messages—which is my use-case (and, it seems, that of a few others in this thread)—it would work fine. You'd just set up the Apply Style to Clipboard action to apply the default message-composition font, font-size, line-spacing, and paragraph-spacing.

I just came up with a wild and wacky (and different) way to solve your problem. Perhaps you won't be happy with my solution, but it's really different and merits a mention.

Most browsers have a status bar (which may not be on by default, so you may have to turn it on) that shows the URL of the link that your mouse is hovering over. The text in this URL is unformatted, which is what you are looking for. It should be easy for someone who knows JavaScript (which I don't) to fetch the contents of the status bar using JavaScript when you click a KM hotkey. There should be no formatting to this string so you can paste it (into the email you are composing, or any other app) without worrying about copying formatting! Bazinga!

I'd also like to see someone write a KM macro that runs in a loop asynchronously and constantly appends any string that pops up in the status bar to some KM variable. I doubt that there is a trigger for this, so it will probably have to use polling in a loop to accomplish this. It would not append the string if the string is already the last line in the variable.


Paste Matching Style doesn't do it, unfortunately. However, I have been messing around with the macro you kindly provided, and so far I can get the html as I want it by saving the results of the macro to the system clipboard and setting all "margin" properties to 0.0px:

I am making some other changes too, such as inserting blank lines between paragraphs:

(It may seem odd to remove top and bottom margins from paragraphs only to then space them out with blank lines, but since Mail doesn't allow control of line- and paragraph-spacing, this at least gives me something predictable.)

Anyhow, my question now is, how do I get the HTML that this creates into RTF?