Besides many other problems in Lion OS X, this one bugged me especially hard. After upgrading the main workstation to Lion I made a very unpleasant discovery. Spotlight was not able to search within source code. A relevant mdi plugin, that was shipped with the previous version of Xcode mysteriously vanished. Yes, it became unavailable.
But fortunately, you still have RichText.mdimporter and you can modify its info.plist to do the job of indexing contents of your source code files on Lion OS X. How to do that.
1) Locate /System/Library/Spotlight and the RichText.mdimporter file.
2) The easiest way – Terminal
|
|
sudo nano /System/Library/Spotlight/RichText.mdimporter/Contents/Info.plist |
3) Add strings for text file types you want to index in Apple UTI notation into dict array, like:
For PHP source files:
|
|
<string>public.php-script</string> |
For JS source files:
|
|
<string>com.netscape.javascript-source</string> |
And so on in the fashion of Apple Uniform Type Identifyers (UTI).
Here is a small list of UTI you may need.
And here is what Apple has to say about UTIs.
Save what you have edited.
3) Reindex your hard drive and enjoy your Spotlight search back again.