Search in all files in a project in Sublime Text 3
Solution 1
You can search a directory using Find
→ Find in files
. This also includes all opened tabs.
The keyboard shortcut is Ctrl⇧+F on non-Mac (regular) keyboards, and ⌘⇧+F on a Mac.
You'll be presented with three boxes: Find
, Where
and Replace
. It's a regular Find/Find-replace search where Where
specifies a file or directory to search. I for example often use a file name or .
for searching the current directory. There are also a few special constructs that can be used within the Where
field:
<project>,<current file>,<open files>,<open folders>,-*.doc,*.txt
Note that these are not placeholders, you type these verbatim.
Most of them are self-explanatory (e.g. -*.doc
excludes files with a .doc
extension).
Pressing the ...
to the right will present you with all available options.
After searching you'll be presented with a Find results
page with all of your matching results. To jump to specific lines and files from it you simply double-click on a line.
Solution 2
You can put <project>
in "Where:" box to search from the current Sublime project from the Find in Files menu.
This is more useful than searching from the root folder for when your project is including or excluding particular folders or file extensions.
Solution 3
Solution:
Use the Search all shortcut: Ctrl+Shift+F, then select the folder in the "Where:" box below. (And for Mac, it's ⌘+Shift+F).
If the root directory for the project is proj, with subdirectories src and aux and you want to search in all subfolders, use the proj folder. To restrict the search to only the src folder, use proj/src in the "Where: " box.
Solution 4
Right click on your root folder, find in folder.
Solution 5
Here's the easiest way : File -> Find in files
![Ivan](https://i.stack.imgur.com/XCWqj.jpg?s=256&g=1)
Ivan
Data Scientist, Systems and Big Data Architect, Physicist
Updated on February 13, 2021Comments
-
Ivan over 3 years
Is there a way to search for a string in all files inside a project in Sublime Text 3? The string is not a method.
-
Ivan over 10 yearsCan you add info about the Where box?
-
Ivan over 10 yearsThanks! I had to fiddle a bit with the "Where:". I thought it was from the project root, but if the root is proj and I want to search in proj/src, I have to type proj/src in Where.
-
Alexander Morland almost 10 yearsUpdated with info about Where box and how you can put <project> there
-
gmo over 9 years
<project>
was a very nice trick!... Thank's for that. Also, (in case someone doesn't know and need it) you can define<open folders>
,<open files>
, filters... or mix them with acomma
. -
keyser about 9 years@gmo yup, added info about those and the
...
button now -
soundly_typed about 9 yearsInstead of double-clicking on a line, is there a keyboard shortcut?
-
keyser about 9 years@mindeavor You can cycle through the results using F4 (forward) and shift+F4 (backwards) on Windows. See the
Find --> Find Results
tab. -
soundly_typed about 9 years@keyser Amazing! For the record, in the
Find in files
tab that opens up after searching, pressing F4 will also open the next result after your cursor! :D -
Jim Hall over 8 yearsWhat about using splats or regex in the
Where
field? For example, I would like to do a search in all files with*-view.js
in the file name. -
Giancarlo Gomez over 8 yearsThank you so much for the <project> trick. I was having an issue where Sublime 3 search was so slow when I had the full path to the directory project (network volumes only - fast on local) and adding <project> instead made it search FAST as hell again!!!
-
Labanino about 8 years@keyser I am using a WordPress starter kit for a new project and I want to replace the name of the theme. In Atom when you hit replace it does just that but in Sublime you get a result page. So, is there a shortcut for not clicking all results? because they are way to many!
-
ch271828n about 8 years⇧ means
Shift
. (I am such a fool to regard⇧
asup
in the very beginning) -
Muhammad Umer about 8 yearscan i do
<project>/frontend
-
adibender almost 8 yearsIs there a way to exclude a folder? Or folders with a certain name?
-
keyser almost 8 years@adibender yes, you exclude stuff using the
-
prefix followed by a pattern that matches folders as well, for example-Test*
to exclude any file or folder that starts withTest
-
adibender almost 8 years@keyser Fantastic! Thank you very much!
-
WesternGun over 6 yearsThis is the way.... it does recursive search in the project. Only specifying folder does not work. Thanks!
-
Martin Thoma over 6 yearsI don't see the "where:" box
-
Martin Thoma over 6 yearsIt's not there (anymore)
-
Mohammad Heydari over 6 yearsAlthough it's not there anymore, it's for version 2
-
Merlin about 6 yearsis there a way to filter or sort results based on file modified date?
-
bantya about 6 yearsThe double click on find file line is what I was looking for. You saved my day!
-
Stiger almost 5 yearsIt doesn't work. When I input
Where
(folder path on my mac) andFile
, it returns empty immediately, even that folder has thousand of files. -
Elouan Keryell-Even almost 5 yearsToo bad there are not placeholders, it would be cool to do
<project>/sub/path
:'( -
hello_there_andy over 4 years@WesternGun thanks you took the words out of my mouth but I still have another question, does it do recursive search from the root /? At which depth does it stop? Can we change this behaviour somehow to make it deeper?
-
WesternGun over 4 years@hello_there_andy it does not begin from
/
, but from the folder you put into "Where". I think it will not stop at certain depth; it will reach till the very deepest, if you understand what I mean :) -
hello_there_andy over 4 years@WesternGun, i totally do know what you mean ;) perhaps the st3 i'm using needs to be updated, because there almost certainly is a max depth i tried it out using a test dir with many many sub dirs, and sub sub dirs... sigh. time to look at the config file
-
WesternGun over 4 yearsIn my PC 20 levels seems to be the upper limit for now. Maybe reducing some levels? It now is off-topic.
-
medmek about 3 yearswould it be difficult to select a folder in the left panel and press
ctrl+shift+F
and have that folder automatically added to theWhere
field in the search (as jetbrain did) -
medmek about 3 yearswould it be difficult to select a folder in the left panel and press
ctrl+shift+F
and have that folder automatically added to theWhere
field in the search (as jetbrain did) -
Jonathan Rys about 3 yearsI just updated to Build 4107 and this no longer works the same for me. Searching
/Users/my_name/my_folder/
used to search in 3800+ files (withnode_modules
excluded) now it only searches in 760 files. Any ideas why this is the case? Not excludingnode_modules
makes it 2650 files searched now.