Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 732
Eric Schnipke Avatar asked Feb 07 '23 07:02

Eric Schnipke


1 Answers

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.

like image 148
Frank Tan Avatar answered Feb 13 '23 01:02

Frank Tan