Eric Schnipke
Eric Schnipke

Reputation: 501

Sublime Text 3 - 'Find in Files' in Subdirectory/Subfolder of Project Source Tree

Background

I am working on a project that has a very large source tree. Since the source tree is large, the 'find in files' functionality of Sublime Text 3 takes quite some time to complete its search. I know that the symbols for which I am searching will only occur in certain (perhaps multiple) subdirectories of this source tree.

Question

Is there a way to restrict the 'find in files' functionality of Sublime Text 3 to search multiple (but not all) subdirectories of a project source tree?

Upvotes: 4

Views: 4625

Answers (1)

Frank Tan
Frank Tan

Reputation: 4412

Let's say you have a folder structure like this opened in Sublime Text:

root
    other
        bar
        foo
    target
        bar
        foo

We want to search in target.

  1. Open the find panel with Ctrl + Shift + F.
  2. In the Where field, add this filter:

    target/
    
  3. Search

The filter means "Search in any files that have a folder named target in the path.

You can be more specific by including more of the path, e.g. target/foo/. This will search in root/target/foo/, but not root/other/foo/.

Specify additional subdirectories by separating with commas, e.g. target/foo/,other/bar/.

Official Search and Replace documentation

You'll probably eventually also want to filter by file type. See this SO question for how to do that.

Upvotes: 9

Related Questions