There are lots of ways to find words and phrases within text files on your Mac. You can use Spotlight, of course, or open those files with a text editor such as TextEdit, BareBones' TextWrangler, or any of the other hundreds of text editors out there. If you're Terminally-inclined, you can open and search text files in vi, nano, or emacs. But here's an alternative you may have never considered: Safari. In particular, Safari 3.0 or later.
In the latest versions of Safari, Apple introduced an enhanced find mode that does a few things when you search for words on a Web page: the background dims to a mid-level gray, matching words are highlighted against a white background, and the currently-selected matching words are shown against a bold yellow background. Taken as a whole, this feature set makes it really easy to visually spot all the matches on a page, focus on the currently-selected match, and yet still easily read the surrounding text for content.
But who says you have to use Safari's nice find features on a Web page? Safari can open any plain text file on your hard drive, in one way or another. Most text files should open just fine using Safari's File -> Open menu. Open the document in question, press Command-F to start a search, enter your search terms, and enjoy the result.
While Safari can open and read most any plain text file, you may find that the File -> Open menu won't work on files you know are plain text. As an example, if you ask Safari to look in the /var/log folder (where log files reside), you can see the various .log files in that folder, but you won't be able to open them through the Open dialog. Instead, open the folder in the Finder, start dragging the text file you'd like to look at, press and hold Command and Option, and drop the text file on Safari's Dock icon. The modifier keys force Safari to accept the dropped file, even if Safari doesn't know what to do with that type of file. As long as the file really is plain text, it should open and display just fine.
There are some limits to this trick--Safari will not be very happy about opening multi-megabyte files, and if Safari finds more than 100 matches for your search term, it will not highlight all of your matches at once. (If you use Command-G to find the next match, each will briefly flash with a yellow background before dimming to the standard OS X highlight color background.)
I don't think Safari is a replacement for any of the excellent search tools we have at our disposal. It might, however, be useful in particular situations, so file this away for possible future use.
For more Macintosh computing news, visit Macworld. Story copyright © 2007 Mac Publishing LLC. All rights reserved.
- Sponsored Resource:Are you ready for virtualization? Try the sever assessment tool.
- Sponsored Resource:Stay at home servers. Learn more about a home server for your family.
- Sponsored Resource:Get the communications, data, and security a business needs in one neat package. Learn more.
- Sponsored Resource:Learn more about ultra light notebooks from Asus and the best warranty in the industry.
- Sponsored Resource:Thinking about a new Laptop? Lenovo has models to meet everyone's needs.
- Sponsored Resource:Get the truth about remanufactured ink. Learn more from HP.
- Sponsored Resource:Six smart ways to grow small business IT
News For Your Business
- Apple Working to Restore MobileMe Functionality
- Mozilla Plugs Nine Holes in Thunderbird
- Adobe's Photoshop Express Taken Offline for Maintenance
- NetNewsWire for IPhone and IPod Touch
- IPhone Developers Frustrated With App Store





Community Comments