Skip to content

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


This comment has been minimized.

Copy link

@kostasprint kostasprint commented Jan 14, 2014

Thanks ;)


This comment has been minimized.

Copy link

@dakl dakl commented Oct 18, 2014

Works in Yosemite. Thanks!


This comment has been minimized.

Copy link

@lakartoza lakartoza commented Sep 12, 2015

Thank you!


This comment has been minimized.

Copy link

@Fil Fil commented Oct 15, 2015

El Capitan seems to prohibit modification of that file


This comment has been minimized.

Copy link

@tysun 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.


This comment has been minimized.

Copy link

@pn11 pn11 commented Dec 3, 2015


This comment has been minimized.

Copy link

@ghost ghost commented May 3, 2017

Thanks, very useful.


This comment has been minimized.

Copy link

@cseder cseder commented Nov 20, 2018

Markdown to Spotlight

You can do this without disabling SIP by creating a copy of the system RichText.mdimporter, modifying its Info.plist and saving it in /Library/Spotlight.

  1. cp -r /System/Library/Spotlight/RichText.mdimporter ~/
    (This copies the .mdimporter to the root of your user home directory)

  2. You can either use an editor from the command line, or go to a Finder window in your Home folder and do a "Show Package Contents" on the RichText.mdimporter file bundle to get to the Info.plist file and open it with Text Edit or another Text Editor.
    Open the: RichText.mdimporter/Contents/Info.plist Markdown.mdimporter/Contents/Info.plist file and add:


to the array of LSItemContentTypes in that file:


  1. Rename the RichText.mdimporter to Markdown.mdimporter:
    mv ~/RichText.mdimporter Markdown.mdimporter

  2. Copy the new .mdimporter to /Library/Spotlight:
    sudo cp -R ~/Markdown.mdimporter /Library/Spotlight

  3. Use the mdimport command to add it to the metadata indexing system:
    mdimport -r /Library/Spotlight/Markdown.mdimporter
    This command asks the server to reimport files for UTIs claimed by the listed plugin.

  4. It should re-import the files automatically after the previous caommand, but if you wish, you can always re-index the whole drive to include the new filetype by rebuilding the whole Spotlight index:
    sudo mdutil -E /
    (This will take some time, and is rather resource demanding)

But now you should be good to go with .markdown files being indexed by Spotlight!

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