Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limit File Search Scope in Sublime Text 2

People also ask

How do I search for a file in Sublime Text?

You can use the Goto Anything feature ( Ctrl + P on Windows and Linux, Cmd + P on macOS) and type the name of the file you're looking for. If there are multiple hits, you can select the appropriate file using cursor keys.

Can Sublime Text handle large files?

Now we know Sublime Text may handle 1GB files, but only the Vanilla version, because if there are more packages installed, they will hang Sublime Text due the issue #1463 Packages are allowed to hang Sublime Text Indefinitely.

How do I select multiple files in Sublime Text?

Multiple Selections To select multiple regions using the keyboard, select a block of text, then press Ctrl+Shift+L to split it into one selection per line. When you're done with using multiple selections, just press Ctrl+K to trim all but the first.


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"],

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".


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.


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


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>

For SublimeText 2, this is working great for me.

When you choose Find in Files, specify exclude folders in Where input;

-bower_components/**/*, -dist/**/*, -node_modules/**/*, -tmp/**/*

So, a hyphen followed by exclude pattern for folders you don't want to search in.

-folder1/**/*, -folder2/**/*

This will limit your searching scope.

See this


I think many of these answers span a few different versions of Sublime Text, here's how I do this with Sublime Text 3 on a Mac.

  1. Open the Sublime Text > Preferences > Settings - User menu
  2. Edit the file_exclude_patterns and folder_exclude_patterns values to ignore files and/or folders from the Find tool

Example

"file_exclude_patterns":
[
    ".svn",
    ".git",
    ".hg",
    ".md",
    ".txt",
    ".DS_Store"
],
"folder_exclude_patterns":
[
    "node_modules",
    "bower_components",
    ".svn",
    ".git",
    ".hg",
    "CVS",
    "deprecated",
    "cache"
],

Screenshot

enter image description here