Skip to content

Instantly share code, notes, and snippets.

@tbartelmess
Created June 23, 2014 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbartelmess/08174bba32a72762c41f to your computer and use it in GitHub Desktop.
Save tbartelmess/08174bba32a72762c41f to your computer and use it in GitHub Desktop.
SubEthaEdit script to cleanup trailing whitespace
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