Spotlight is a great tool for finding documents, music and other files on your Mac, but it won't search for certain kinds of files. If you need to locate a specific hidden, packaged or system file, here's how to go about it.
Spotlight has some seriously awesome features—like being able to search the content of a document in addition to just the file name—but when it comes to the system files, such as those buried deep in the ~/Library folder, Spotlight leaves a bit to be desired out-of-the-box.
Tweaking Spotlight to Find System Files
Say you're troubleshooting an app, and you want to start over with a clean slate by deleting its .pref file. These files often have strange names that make them hard to find alphabetically in ~/Library/Preferences. Searching for the application's name would be a great solution, but Spotlight doesn't search system files by default. With a small tweak, though, you can choose to include system files in specific searches.
Just open up Finder and search for a file. When the search begins, a new bar shows up in the Finder with the options so search a specific folder and whether to search its filename or contents. On the right side of this bar is a plus sign. Hit that to bring up another menu with more options. In the dropdown that says Kind, choose Other. Use the search box to find "System Files" in the menu, and check its box. When you hit OK, "System Files" will be an option in that leftmost dropdown menu. Click it, and in the dropdown to the right of it, choose "Include". Spotlight will then extend your search to include system files and you can find the file in question.
Using Find Any File to Search Packaged and Hidden Files
Unfortunately, this method only works for finding system files. It won't find hidden files (even if you have Finder set to show hidden files), and it won't find files inside packages. For these, you'll need an external program. Free app Find Any File is a very simple search app that gives you these options in the form of simple checkboxes. Just search for your file, and when the results window pops up, check the box to include hidden files or files inside packages:
It isn't quite as fast as Spotlight, but it serves its purpose well when you need to get at files that Spotlight tries to keep out of your way.
These are just a few methods for finding files that Spotlight doesn't include in its searches by default, but its likely that there are other types of files that aren't Spotlight-friendly—if you have any tips for getting around Spotlight's limitations, share them with us in the comments.