Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.6: Create a 'copy as plain text' service System 10.6
I ran into an issue where I need to copy some items from Numbers into a table in Keynote -- but they kept copying as table cells, thus inserting new cells and messing up my existing table. At first, my only solution was to copy from Numbers, switch to TextEdit, paste-and-match-style (Shift-Command-Option-V), recopy, switch to Keynote, and paste. Not terribly efficient.

With the help of this hint, I realized there was a better way, provided you have GUI scripting turned on. As a bonus, it solves the copy (or paste) as plain text problem for all apps, not just these two

Here's the fix: in Automator, create a new Service, and set it to receive no input and work in any application. Add a Run AppleScript action, and put the following code in the on run routine:
tell application "System Events"
  keystroke "c" using command down
end tell
	
delay 0.05
	
try
  set the clipboard to string of (the clipboard as record)
on error errMsg
  display dialog errMsg
end try
This just presses Command-C to copy, and then converts the clipboard to plain text. The delay is necessary to make sure the clipboard gets populated before the conversion happens. I saved this as Copy Plain Text, and assigned it the Control-Shift-C shortcut.

It's also pretty easy to setup a parallel Paste Plain Text service, with this code:
try
  set oldClipboard to (the clipboard as record)
  set the clipboard to string of (the clipboard as record)
on error errMsg
  display dialog errMsg
end try
	
tell application "System Events"
  keystroke "v" using command down
end tell
	
set the clipboard to oldClipboard
This one is just a little more complicated in order to restore the formatted version of the clipboard after pasting the plain text. You can also set up a keyboard shortcut for this, of course, and it's pretty easy to imagine a "Cut as Plain Text" service as well.

[robg adds: I haven't tested these.]
    •    
  • Currently 2.36 / 5
  You rated: 4 / 5 (11 votes cast)
 
[13,918 views]  

10.6: Create a 'copy as plain text' service | 7 comments | Create New Account
Click here to return to the '10.6: Create a 'copy as plain text' service' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.6: Create a 'copy as plain text' service
Authored by: chanamasala on Sep 23, '09 08:16:57AM

I had to set it to receive text as leaving it to "receive no input" made it never activate.



[ Reply to This | # ]
10.6: Create a 'copy as plain text' service
Authored by: Ilo on Sep 23, '09 08:57:49AM
Wouldn't the free program "Plain Clip" work just as well? Or is that not compatible with 10.6? (I don't have 10.6 yet so I can't test it myself)

http://www.bluem.net/en/mac/plain-clip/

[ Reply to This | # ]
10.6: Create a 'copy as plain text' service
Authored by: tice on Sep 23, '09 10:37:35AM

I made a solution via the great Shortcut app Spark and an Applescript in it:

try
set the clipboard to string of (the clipboard as record)
on error errMsg
display dialog errMsg
end try

cmd-crlt-F does the trick for me without a mouse-and-menue action. : )



[ Reply to This | # ]
10.6: Create a 'copy as plain text' service
Authored by: miles_thatsme on Sep 23, '09 01:51:22PM

I think you should change it so that "Service receives selected"... "Text".

That did not disable it for me. I'm no programmer, but I suspect the purpose of that box is to enable contextual menus, telling the system where and when they should crop up (i.e. when selecting text... in any application).

Regardless of its purpose, that's the effect of ticking the box: you get a contextual menu containing this service when you select text. As I usually select text with my mouse, right clicking to execute this is pretty handy.



[ Reply to This | # ]
10.6: Create a 'copy as plain text' service
Authored by: rmanke on Sep 23, '09 05:36:13PM

One of the "features" of MacOS that drives me crazy is a lack of a standard "Copy as Plain Text" menu item.

This is awesome, thanks!

Note: I also had to select the "text" setting for it to work. (You might want to adjust your example).



[ Reply to This | # ]
The reason for setting it to "no input"
Authored by: designbot on Oct 07, '09 02:22:27PM

If it's set to accept "no input," it will work in any application, even if it doesn't support Services. If it's set to accept "text", it won't work in some applications (such as Adobe Illustrator CS3).



[ Reply to This | # ]
10.6: Create a 'copy as plain text' service
Authored by: DogDutyAscetic on Oct 28, '09 10:44:36AM

I have an alternative and very simple solution. Download Menuclip http://www.clipmenu.com/en/features/ . It's a clipboard enhancement program that's free. It supports paste as plain text as a default action in any application. Besides that it's simply the most brilliant clipboard enhancer on the Mac platform. Check it out. Please donate if you can afford it and you love it.



[ Reply to This | # ]