Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Mac OSX Spotlight Enhancement

Mac OSX Spotlight Enhancement

Add this to Info.plist in /System/Library/Spotlight/RichText.mdimporter/Contents/ and Spotlight will search for source code files.


To find the entry for other file extensions do:

mdimport -n -d1 somefile.ext

After adding the desired file types you have to run

mdimport -r /System/Library/Spotlight/RichText.mdimporter

to update the new file extensions.

To re-index the HD you can run

sudo mdutil -E /

To implement an easy command to search via the Terminal using Spotlight install from

To add system folders to the search index use the script above and execute

spotfind -c

More Information

Thanks ;)

dakl commented Oct 18, 2014

Works in Yosemite. Thanks!

Thank you!

Fil commented Oct 15, 2015

El Capitan seems to prohibit modification of that file

tysun commented Nov 21, 2015

Yes Fil is correct. This is a no go on El Capitan. I even tried adding admin to permissions but I was locked out. Anyone have a workaround? I'd love to be able to index my .swift/.m files.


ghost commented May 3, 2017

Thanks, very useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment