Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

abr88

macrumors member
Original poster
Nov 22, 2015
70
3
I want to find all occurrences of ' ' (not counting the quotes) in a .txt file. Is this possible? When I type the 2 spaces into the "Find" area, it doesn't seem to find them. Thanks.
 
I want to find all occurrences of ' ' (not counting the quotes) in a .txt file. Is this possible? When I type the 2 spaces into the "Find" area, it doesn't seem to find them. Thanks.
I created a text file with some spaces, double spaces and triple spaces, and TextEdit found them all as I typed into the search field. I did notice that there was a second or two of time between me pressing the space bar and the spaces actually being found.
 
That works for me when I just type in 1 space as the target -- all the occurrences of one space turn white. (If there's more than one consecutive space, only the first space shows up white.) But if I continue my "Find" request by hitting spacebar again to type in a second space, TextEdit seems to revert to doing nothing -- nothing shows up in white. Any help much appreciated!
 
That works for me when I just type in 1 space as the target -- all the occurrences of one space turn white. (If there's more than one consecutive space, only the first space shows up white.) But if I continue my "Find" request by hitting spacebar again to type in a second space, TextEdit seems to revert to doing nothing -- nothing shows up in white. Any help much appreciated!
I'm at a loss, my copy of TextEdit.app doesn't act that way and I don't see anything in settings that would interfere with searching. Perhaps someone else can chime in with an answer.
 
Just to clarify -- Finding one space:
Screen Shot 2016-06-06 at 7.36.00 PM.jpg

Daring to type spacebar a second time:
Screen Shot 2016-06-06 at 7.36.25 PM.jpg
 

Attachments

  • Screen Shot 2016-06-06 at 7.36.00 PM.jpg
    Screen Shot 2016-06-06 at 7.36.00 PM.jpg
    139 KB · Views: 159
  • Screen Shot 2016-06-06 at 7.36.00 PM.jpg
    Screen Shot 2016-06-06 at 7.36.00 PM.jpg
    139 KB · Views: 148
  • Screen Shot 2016-06-06 at 7.36.25 PM.jpg
    Screen Shot 2016-06-06 at 7.36.25 PM.jpg
    147.4 KB · Views: 170
  • Screen Shot 2016-06-06 at 7.36.00 PM.jpg
    Screen Shot 2016-06-06 at 7.36.00 PM.jpg
    139 KB · Views: 174
Is it possible that your sample does not have any double spaces? It appears to me that the places that might have double spaces have tabs instead.

DS
 
  • Like
Reactions: ardchoille50
Is it possible that your sample does not have any double spaces? It appears to me that the places that might have double spaces have tabs instead.

DS
I haven't figured out how to get TextEdit.app to find tabs and new lines. This is why I use TextWrangler, you can find tabs with '\t' and new lines with '\n'. I wonder if TextWrangler would suit the OP's needs better than TextEdit.
 
The file is attached. artchoille50: Your theory sounds very possible. Is there a way to "Find" a tab? Glad to try that if I knew how to put a tab in the Find area!
 

Attachments

  • LPs.txt
    2.1 KB · Views: 435
The file is attached. artchoille50: Your theory sounds very possible. Is there a way to "Find" a tab? Glad to try that if I knew how to put a tab in the Find area!
Thank you for supplying the file for me to test. @dsemf was right, the reason you cannot find any two or three consecutive spaces is because there aren't any. There are, however, lots of tabs. The only way to find a tab in TextEdit is to copy one to the clipboard and paste it into TextEdit's search box - TextEdit.app doesn't support searching for tabs with '\t'.

You might want to install TextWrangler, link here. In TextWrangler, you can enter '\t' ,for tabs, and '\n' ,for new lines, in the search field (without the quotes) and it will find them. I have replaced TextEdit.app with TextWrangler on my Mac because it just seems to better suit my needs.
 
It turns out that option-tab can be used as a search argument in TextEdit to match tabs.

DS
Thank you for this wonderful tip! Using your example, I found that the Option+Enter can do the same when searching for new lines.
 
And TextWrangler allows you to edit your /etc/hosts file, which you can't do with TextEdit.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.