Created
June 23, 2014 01:43
-
-
Save tbartelmess/08174bba32a72762c41f to your computer and use it in GitHub Desktop.
SubEthaEdit script to cleanup trailing whitespace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on seescriptsettings() | |
return {keyboardShortcut:"$@c", displayName:"Remove trailing whitespace", inContextMenu:"yes"} | |
end seescriptsettings | |
tell application "SubEthaEdit" | |
set someText to contents of front document as text | |
end tell | |
set cleaned_text to do shell script "echo " & quoted form of someText & " | sed -e's/[[:space:]]*$//' " without altering line endings | |
tell application "SubEthaEdit" | |
if (length of selection = 0) then | |
set contents of front document to cleaned_text | |
else | |
set contents of selection of front document to cleaned_text as text | |
end if | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment