Code Searcher

Version 10

    Please note: This tool is free to use but unsupported.

    Credit: Tool created by Johnathan Kastner, with contributions from Casey Campbell.

     

     

    Use this Code Searcher tool for:

    • Finding code when you only have a vague idea what you're looking for. You can type in a mix of words and get the best match throughout the code base.
    • Finding code via string, even in binary resource files
    • Finding sample code to mimic in unrelated, unknown projects
    • Finding recurrences of a bug in other projects

     

    Launch from CodeSearcher\CodeSearcher.exe.

     

    Set the Target Directory where you would like to execute your search. You can either enter your directory location or click the Browse button to navigate to the folder containing the code you want to search.

     

    cs2-ch.png

     

    To prepare a cache for faster searching, click Create Cache.  When prompted, choose a name and location for the new cache file.  (Alternatively, you can skip caching and jump directly to searching by clicking Read Files.)

     

    Note:  If you have already created caches with this tool, use the Open Cache button to load a previous cache file instead of recreating it.  The button to its right is a shortcut that opens your most recent cache file.  The name of this button will always show the name of your most recent cache file (it is titled "Project ABC" in the picture above, because the cache file I most recently search with is named Project ABC). This button will only appear after you have created at least one cache.

     

    After the cache is created, a Search Source window opens.  Enter your search string in the top field, then click the Search button.

     

    cs3.png

     

    All files containing at least one match now appear in the window.  You can right-click any matching file to open it or to remove it from the search results.  If you hover over a search result, you will see a snippet of the code with an arrow pointing to a line where the search match is found.

     

    Double-click a match to open it in a viewer window.  Click Next to cycle through the matching lines within this file.

     

    cs6.png

     

     

    Some search tips:

     

    1. Previous/Next Search - Click the back and forward arrows to quickly go back to a previous search with the same results already waiting. This is made possible via object immutability.

     

    2. Multiple search terms - The tool supports a mix of terms.

     

    3. Reformatting - The results are scored by match on four factors, with the best line visible beneath each result.

     

    4.  Search within the current set of results.

     

    5. Multiple 'best' results - Each search result can be visited.

     

    6.  Search exclusion using hyphen ( - ).   Entire lines of code can be excluded with a leading hyphen.

     

    7. Caching -  Additionally, a command line tool can create caches via a bat file or similar command.