Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Mail strike through keyboard shortcut

For years I'm trying to find a keyboard shortcut for 'strikethrough' or 'struck through' or however you want to call text with a horizontal line through it in OS X Mail. You'd think it is a popular feature since the strikethrough style has been on text editors since the earliest days of the Mac, well at least for decades I can remember and on the other hand it's easy to implement in HTML email since there's a HTML tag for it, <s>triketrough, just like there is for <b>old and <i>talic.


I did manage to add a shortcut for strikethrough by adding a style to 'favorite styles' via the 'system wide' styles menu.


(You can do this by making a text selection strikethrough and then add this style to the styles menu via, for example, using the right mouse button or CTRL-clicking on a text selection and choosing Fonts, submenu Styles. I named it Struck though (or maybe it was already there, I'm not sure).


Then I added a shortcut for it in System Preferences / Keyboard / Shortcuts


(Select Applications in the bottem of the left colomn, click the + sign below the second column, choose 'All applications' else it won't work in Textedit for some reason, name it EXACTLY after your menu item, for example in my case Struck through — and choose a keyboard shortcut that is not already in use. Watch out: somehow it doesn't warn you any more for used shortcuts. If I recall correctly it did warm me in older versions of OS X.)


This shortcut is working in Textedit but still not in Mail. I really hoped this new version of Mail 5.2 would finally have a fix for this. Is there really no way to use a shortcut for strikethrough in Mail?

MacPro3,1 (2008), Mac OS X (10.6.4), working with Macs since 1992

Posted on May 20, 2012 5:00 PM

Reply
Question marked as Best reply

Posted on Apr 30, 2013 2:03 PM

Command-T brings up the Fonts window and strike-through is available there.


<Image Edited by Host>

29 replies

Aug 13, 2015 8:57 AM in response to Leon Buijs

The GUI scripting solution that I alluded too earlier worked in Mavericks, but no longer works on Yosemite. Not much surprise there.


The simplest solution (before El Capitan Mail) has already been mentioned: command-T. If you want red strike-through, choose the color from the strike-through menu before applying the strike-through itself.


And if one cannot be bothered with mere command-T as a solution, and prior to installation of released El Capitan, I wrote an AppleScript and shell script combination that messages the clipboard RTF text, and inserts a strike-through in the selected text. I built this into an Automator Service, and as you know, a keyboard shortcut can be assigned. This solution works on Mavericks and Yosemite 10.10.4 and completely eliminates the breakage of GUI scripting.


Usage: Simply select the text for the strike-through (ensure there is whitespace behind the selection), and it will be automatically copied to the clipboard, a strike-through applied in the RTF clipboard content, and pasted back into your text selection.


Here is the Automator Service workflow:


User uploaded file


Open a new TextEdit document, and from the format menu, choose make plain text (if you don't have a programmer's editor), and copy/paste the following Bash script into it. Save it, and change its location accordingly in the Automator AppleScript accordingly.


#!/bin/bash

#

# rtf_strike.sh

#

# get the raw RTF code from the clipboard, retaining all of the original

# copied selection characteristics (e.g. font, color, size, etc.). Use Perl to

# massage the RTF code, and sed to insert the RTF strikethrough operator

# to produce the strike-through effect on the original selection. Toss it

# back on the clipboard when done.



# Reference

## stackoverflow dot com/questions/2545289/getting-rtf-data-out-of-mac-os-x-pasteboard-clipboard



/usr/bin/osascript -e 'the clipboard as «class RTF »' | \

/usr/bin/perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | \

/usr/bin/sed -e 's/\\cf/\\strike\\cf/;$s/}$/\\strike0}/g' | /usr/bin/pbcopy



exit 0

Aug 13, 2015 11:22 AM in response to VikingOSX

VikingOSX wrote:


That GUI script solution now (haha) breaks in Yosemite 10.10.4.


You're right, as always. However, my previous version of a GUI script can be updated for Yosemite 10.10.4 as follows :


tell application "Mail"

activate

repeat until frontmost is true

end repeat

end tell


tell application "System Events"

tell process "Mail"

set flag to (window "Fonts" exists)

if not flag then

keystroke "t" using {command down}

repeat until window "Fonts" exists

end repeat

end if

tell menu button 1 of group 3 of toolbar 1 of window "Fonts"

click

clickmenu item 2 of menu 1

end tell

if not flag then keystroke "t" using {command down}

end tell

end tell


And, again, just replacing “click menu item 2 of menu 1” with “click menu item 1 of menu 1” in the above script, you could easily write another script that would remove strikethrough.

Nov 14, 2015 12:27 PM in response to VikingOSX

I'm in awe of VikingOSX' automator tricks and though it took me some time, I got the script to work (before the update broke it again). I hope you don't think I'm a complete *** for saying it was quite a slow solution my rMBP 2013.


Unfortunately the new button doesn't change the fact that one still needs to take a hand of the keyboard to click it with the mouse.


I tried to set a System preferences / Keyboard / Shortcut to use it but since it's not in the top menu or one of it's submenus, this still doesn't work. 😟

Mail strike through keyboard shortcut

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.