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
42
1
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.
 

ardchoille50

macrumors 68020
Feb 6, 2014
2,142
1,224
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.
 

abr88

macrumors member
Original poster
Nov 22, 2015
42
1
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!
 

ardchoille50

macrumors 68020
Feb 6, 2014
2,142
1,224
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.
 

abr88

macrumors member
Original poster
Nov 22, 2015
42
1
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: 109
  • 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: 99
  • 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: 123
  • 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: 116

dsemf

macrumors 6502
Jul 26, 2014
417
98
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

ardchoille50

macrumors 68020
Feb 6, 2014
2,142
1,224
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.
 

abr88

macrumors member
Original poster
Nov 22, 2015
42
1
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: 379

ardchoille50

macrumors 68020
Feb 6, 2014
2,142
1,224
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.
 

ardchoille50

macrumors 68020
Feb 6, 2014
2,142
1,224
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.
 

JohnDS

macrumors 65816
Oct 25, 2015
1,183
249
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.