Find/Replace Double Space in TextEdit?

I have tried MANY different combinations and can't seem to find out how to replace double spaces with single spaces. I've tried as many combinations of every syntax that seemed relevant below

*from an apple sample ****

-- NOT A FUNCTIONAL SCRIPT. JUST EXAMPLES OF SYNTAX.
tell application "TextEdit"
tell text of document 1
set the color of every word where it is "Verdana" to {65535, 0, 0}
set the color of every paragraph whose first word is "Marker" to {0, 0, 65535}
set the color of every paragraph whose first character of its second word is "G" to {0, 65535, 0}
set the color of every paragraph whose contents contains "Sans" to {0, 65535, 65535}
set the color of every paragraph where it contains "Sans" to {0, 65535, 65535}
set the color of every word where it is "fox" to {0, 0, 65535}
set the color of every text whose contents is "brown" to {0, 0, 65535}
set word 5 to "Shoe"
set every word where it is "Light" to "Dark"
set every attribute run where it contains "Narrow" to "TEXT REMOVED"
set every paragraph where it contains "Negative" to ("---- REPLACED ----" & return) as string
delete (every paragraph where it contains "Bold")
delete (every word where it is "jumped")
end tell
end tell

**************************

How can I designate a string of characters I want replaced. "Word" definitely doesn't work in this case. Any help appreciated.

24" iMac - Core 2 Duo 2.16, Mac OS X (10.4.8), 2GB RAM • GeForce 7600 GT • 3G iPod 10GB

Posted on Feb 28, 2007 7:32 AM

Reply
3 replies

Feb 28, 2007 9:41 AM in response to zwei

Hi Zwei,

The quickest and easiest way to replace text in TextEdit is to overwrite the text. e.g.

set s to space & space
set r to space
tell application "TextEdit"
activate
set t to text of front document
end tell
set t to ReplaceText(t, s, r)
tell application "TextEdit"
set text of front document to t
end tell
--
on ReplaceText(t, s, r)
set utid to AppleScript's text item delimiters
set AppleScript's text item delimiters to s
set temp_list to text items of t
set AppleScript's text item delimiters to r
set temp_text to temp_list as string
set AppleScript's text item delimiters to utid
return temp_text
end ReplaceText

gl,

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Find/Replace Double Space in TextEdit?

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