Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question
    
It looks like Spotlight should be treating the underscore as a word separator. If you rename the file to "Important Exotic Class.h" (replacing the underscores with spaces), or create a new text file with that name, will Spotlight then include that file when you search for "Exotic"? –  joelseph Oct 3 '11 at 7:18

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
"Name" and "contains" do indeed reveal between-the-underscores words. One can even restrict the search to a given pair (word1_word2). –  Calaf Oct 4 '11 at 3:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.