Can Spotlight be easily configured to search text files?

Discussion in 'Apple' started by jbrecht, Feb 2, 2007.

  1. jbrecht

    jbrecht Guest

    I've found old posts on this topic and am hoping maybe things have
    changed... I'd like to be able to search plain text files
    - .java, .css, .xml, etc... I've found a number of elaborate hacks out
    there, but none work particularly well. I even went to the extent of
    downloading and installing XCode (1 GB DL just to search!) and thought
    for a while there that I might have finagled this machine into
    searching the text of such files, but it still doesn't work.

    Is there any solution to this problem that is relatively
    straightforward and that works with any consistency?

    I am a recent switcher and the inability to search for text in files
    is the biggest thing making me want to switch back. Windows has done
    this for a decade, why can't Mac?
     
    jbrecht, Feb 2, 2007
    #1
    1. Advertisements

  2. jbrecht

    matt neuburg Guest

    I'm not clear what the trouble is supposed to be. Spotlight does search
    plain text files. For example I just made and saved a .xml found. I used
    Spotlight to search for a word I knew was in it, and Spotlight instantly
    found the file. m.
     
    matt neuburg, Feb 2, 2007
    #2
    1. Advertisements

  3. Windows has done it unreliably for a decade, and the specific conditions
    that disable content searching vary from one version of Windows to
    another. For example in NT you couldn't do content searches on read-only
    files. In XP, IIRC, you have to have an editor defined for the file
    extension in the registry.

    Spotlight's biggest downfalls are related to that latter issue for
    Windows. You don't have to have an editor defined but you do have to
    have an indexing plugin that claims to be able to understand that file
    type _and_ it has to actually do so in a reasonable way. Installing
    Xcode should have given you a plugin that claims to be able to handle
    source code files in several different languages. Looks like it claims
    specifically to support source and header files for C/C++/Obj-C and
    source for Java. Running a quick test, it's working fine here.
     
    Gregory Weston, Feb 2, 2007
    #3
  4. jbrecht

    Alex Hunsley Guest

    I've just posted an almost identical seperate thread!
    Since my post, I've found several free spotlight replacements:

    SpotLaser: http://members.optusnet.com.au/frovil/spotlaser.html
    NotLight: http://www.versiontracker.com/dyn/moreinfo/macosx/29015
    EasyFind: http://www.devon-technologies.com/products/freeware/index.html
    NameFind: http://www.versiontracker.com/dyn/moreinfo/macosx/29104
    LiveSearch: http://www.versiontracker.com/dyn/moreinfo/macosx/20044
    FoxTrot Personal Search:
    http://www.versiontracker.com/dyn/moreinfo/macosx/28446


    Also, there's an interesting article here about troubleshooting
    SpotLight issues:
    http://www.macfixit.com/article.php?story=20061109235901299
     
    Alex Hunsley, Feb 2, 2007
    #4
  5. jbrecht

    Paul Sture Guest

    For a slightly different approach, you can use TextWrangler's multi-file
    search capability. You can apply file filters, specify whether or not to
    search into nested directories, and also save searches.

    I prefer this approach from the point of narrowing the search down to a
    specific project or even sub-project.

    TextWrangler is free and can be obtained from

    <http://www.barebones.com/products/textwrangler/>

    If you do decide to have a look at it, please take the time to do the
    tutorial; it is worth the effort.
     
    Paul Sture, Feb 2, 2007
    #5
  6. jbrecht

    David Emme Guest

    You might want to take a look at SpotInside:

    http://www.oneriver.jp/SpotInside/index.html

    -Dave
     
    David Emme, Feb 2, 2007
    #6
  7. jbrecht

    jbrecht Guest

    Yeah, this is what I was afraid of, that the only solution is 3rd
    party. (So far my workaround for this problem has been to use text
    editors or IDEs that can do file search, such as the Text Wrangler
    recommendation.) The promised "it just works" does not apply to text
    search on Macs I guess.

    Thanks for this list of alternatives!
     
    jbrecht, Feb 2, 2007
    #7
  8. jbrecht

    jbrecht Guest

    Never had that issue with Windows before. I've always been able to
    search for filenames containing *.java and then specify some search
    text and I'm good to go, no special configuration. I'll mess around
    with XCode configuration some more, but it still seems obscene that
    you need a 1 GB "plugin" that you then need to go through some arcane
    configuration with just to enable text search.
     
    jbrecht, Feb 2, 2007
    #8
  9. Be happy your search set didn't trip over the undocumented limitations.
    It was especially thrilling when we moved to XP because our IT group
    took admin control away from engineers at the same time. Suddenly I
    couldn't do content searches on certain files just because they didn't
    have an editor defined in the registry _and_ I had to file a maintenance
    request to get it fixed instead of doing it myself in 30 seconds.

    At least when it didn't work within read-only directories I could've
    (usually) copied the data to a different location long enough to do the
    search.

    Bleah.
    You don't. You need a 48k plugin to handle source code (which has
    different indexing characteristics than generic text tends to). The
    simplest way to get that plugin is to install the dev tools (which
    probably 85% of the people who want to search in source files on their
    machine are likely to have done already) but it's not the only way.


    G
     
    Gregory Weston, Feb 2, 2007
    #9
  10. jbrecht

    jbrecht Guest

    *how* it "doesn't work" is if I search for, say "import" (which should
    be in every java file), no java files turn up. If I search for "java",
    I'll find java files. but then if I refine the search term by adding a
    "Contents" search for "import", again nothing turns up, at least not
    java source code.

    on another machine, i tried installing XCode, and hacking around the
    info.plist file for the mdimporter associated with source code and
    kinda got things working for a while (though it still didn't succeed
    consistently.) regardless, that's a ridiculous amount of work to do
    just to get plain text search. I am now on different machine and in a
    situation where a 1 GB download is out of the question, so I'm asking
    if there is any alternative to downloading XCode and hacking plist
    files.

    thanks for the help!
     
    jbrecht, Feb 2, 2007
    #10
  11. jbrecht

    jbrecht Guest

    can that 48k plugin be downloaded somewhere? i've searched for java
    plugins for spotlight and only turned up one that will search jar
    files.
     
    jbrecht, Feb 2, 2007
    #11
  12. I'm not aware of a link to any information about it. It's a SpotLight
    importer plugin. It overrides the generic text importer for C-ish and
    Java source files. What do you need to know?
     
    Gregory Weston, Feb 3, 2007
    #12
  13. Where's it installed? What's the file name? Anything![/QUOTE]

    /Library/Spotlight/SourceCode.mdimporter

    Try "mdimport -L" in a terminal window for a list of all importers.
     
    Gregory Weston, Feb 3, 2007
    #13
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.