Convert Spaces to Dashes TextExpander Snippet (Updated)


A while back I posted a TextExpander snippet to replace spaces with dashes. I find it frequently helpful but it always annoyed me that it couldn’t be used inside other snippets.

Well, I fixed it. This Applescript version can be used inside any of your other snippets as a nested snippet.

set fillin to "%%filltext:name=Title%%"
set var to words of fillin
set AppleScript's text item delimiters to {"-"}
set dashedvar to var as string
set AppleScript's text item delimiters to ""
return dashedvar

It’s also quite easy to adapt. For example, here’s a version that changes dashes to & nbsp; escape characters:

set fillin to "%%filltext:name=Title%%"
set AppleScript's text item delimiters to {"-"}
set var to words of fillin
set AppleScript's text item delimiters to {"& nbsp;"}
set dashedvar to var as string
set AppleScript's text item delimiters to ""
return dashedvar