Indexing words separated by underscores

When searching using Spotlight for, say, the word "Exotic", it fails to report the file Important_Exotic_Class.h, containing a C++ class by that name.

Can you think of a method to make Spotlight index the portions of identifiers between underscores in .h and .cpp files? In the example above, the three words would be indexed.

Even just indexing the words between underscores in filenames would be very useful.


Spotlight should already index these files, it does on my Mac. Try searching for them as follows:

  • Open a Finder window
  • Press Command+F
  • Change the search parameters to "Name" and "contains" to search for file names or just "Contents" to search text within the files
  • Enter your search term

Once you start typing, spotlight should start showing results in the window

Note: Check in the 'Privacy' tab of the Spotlight preference pane in System Preferences to ensure you haven't excluded the folder/drive where your .h and .cpp files reside.