How to paste from iClip and match style?

Apps often have a special Paste command titled Paste and Match Style. How can the same effect be accomplished when pasting from iClip?

Technically, the pasted data must not include formatting information. In other words, you'd want to paste plain text, not rich text.

iClip has several ways to accomplish that:

Using the paste arrow button

When you paste a clipping by clicking on the little arrow, then hold down the "cmd" key first, and keep holding it until you've clicked. While holding the cmd key, the arrow will show a little icon like this:

Using the dedicated "Paste plain text" hot key

You can define a hot key in iClip's Preferences for "Paste plain text from bin...". If you then press that hot key, you get to select the bin to paste from (for the more recent added to the Recorder type "1"). See iClip's Help for details.

Using the normal "Paste" hot key (works only in version 5.2.3 and later)

Similar to the previous procedeure, you can define a hot key in iClip's Preferences for "Paste from bin...". That usually pastes the rich text if you select a bin and press the Return key, i.e. it retains the formatting of the clipping. But if you hold down the Option (alt, ) key when pressing the Return key, the formatting will get removed from the pasted text.

Converting a rich text clipping to plain text before pasting it

You can click on the clippings' gear icon and choose "Make plain text" from the menu. After that, paste the bin to the document.

Removing the formatting automatically from all clips when they get added to iClip

With iClip's new scripting feature, you could also have all formatting automatically and immediately removed from every text clipping you add to iClip.

Or only to all clippings of a particular Clip Set, or only for clippings from particular applications.

This requires some AppleScript programming skills, though. To learn more about scripting, see iClip Scripting.

Basically, you'd extend the "iClip Events.scpt" script's filter incoming flavors handler. (You can download this script via the link above.) To remove formatting from all scripts, it would look like this:

	on filter incoming flavors
		tell first clip item of current clipping
			if name of flavors contains "public.utf8-plain-text" then
				delete (flavors whose scrap type is "weba")
				delete (flavors whose scrap type is "rtfd")
				delete (flavors whose scrap type is "RTF ")
				delete (flavors whose scrap type is "ustl")
				delete (flavors whose scrap type is "styl")
			end if
		end tell
	end filter incoming flavors

Modify the iClip Events to use the above code and save the script (it should be placed into in the iClip Support folder's Scripts folder). After a few seconds, iClip will see the updated script and use it. Make a text by copying text from a web page or from a rich text document, e.g. made with TextEdit. Then check in iClip, e.g. by moving the mouse over the just-recorded clipping, to see what the pop-up preview window shows as the type. It could show "Plain text", not "Web clipping" nor "Rich text".

If you want to remove the formatting only for clippings made from a particular app, e.g. Apple's TextEdit.app, the code would get added a check for that app's Bundle ID:

	on filter incoming flavors
		set bundleID to app id of current clipping
		-- debuglog "bundle ID: " & bundleID
		if bundleID is "com.apple.TextEdit" then
			tell first clip item of current clipping
				if name of flavors contains "public.utf8-plain-text" then
					delete (flavors whose scrap type is "weba")
					delete (flavors whose scrap type is "rtfd")
					delete (flavors whose scrap type is "RTF ")
					delete (flavors whose scrap type is "ustl")
					delete (flavors whose scrap type is "styl")
				end if
			end tell
		end if
	end filter incoming flavors

The line with debuglog in it, which is currently commented out (by prepending the line with "--"), can be used to see the appID. To use that, remove the "--" and save the script again, then open Console.app. Next time you copy something, Console should show a line like this:

07/08/16 18:03:33,387 iClip[41415]: bundle ID: com.apple.Safari

That indicates that the Copy was made in Safari when iClip recorded it.