Limit File Search Scope in Sublime Text 2

Solution 1:

Add and edit this in your ~/Library/Application Support/Sublime Text 2/Packages/User/Preferences.sublime-settings file.

// These files will still show up in the side bar, but won't be included in
// Goto Anything or Find in Files
"binary_file_patterns": ["*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf", "*.tga", "*.dds", "*.ico", "*.eot", "*.pdf", "*.swf", "*.jar", "*.zip"],

"folder_exclude_patterns": [".svn", ".git", ".hg", "CVS"],

Solution 2:

For Sublime Text 3: To exclude from search and GoTo results, without removing from the sidebar, change the "binary_file_patterns" setting. Matches files AND folders.

For example, to exclude files in "dist" and "node_modules" from GoTo indexing, add this to your User Settings file:

"binary_file_patterns": ["dist/*", "node_modules/*", "*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf", "*.tga", "*.dds", "*.ico", "*.eot", "*.pdf", "*.swf", "*.jar", "*.zip"]

I can't figure out how to implement this on a per-project basis :(. Most settings can be moved to a project.sublime-project file. "Project > Save Project As", save it the root of your project, and add "settings": {...} to the json in the generated file. (from source, works as of ST3 build 3095). But does not work with "binary_file_patterns".

Solution 3:

You can exclude certain file patterns and folders from your project by modifying your project settings like so:

{
    "folders":
    [
        {
            "path": "src",
            "folder_exclude_patterns": ["backup"]
        },
        {
            "path": "docs",
            "file_exclude_patterns": ["*.css"]
        }
    ]
}

This is described in the projects documentation.

Solution 4:

You can also exclude folders in the Find All pane by using the -*/foldername/* syntax in the Where field - eg:

-*/node_modules/*

http://www.sublimetext.com/forum/viewtopic.php?f=2&t=3847&start=10

Solution 5:

In sublime text 3 (BLD 3059 Windows) I needed to restrict the "find in folder" function to certain files / folders and maybe a single file,

The following works for me Contents of the where: box

/C/path/2/project/folder,*.c,*.h,-*/path/not/to/look/in,/C/path/2/specific/file/file.h

Taking it further without absolute paths, you can combine the above with the following symbolic locations

<open folders>, <open files>, <current file>

<open folders>,*.c,*.h,-*/never_this_in_folder/*,<open files>