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.
-
49ctrl+shift+f, then simply select root folder in `Where:` – Tobberoth Dec 11 '13 at 12:27
-
1http://superuser.com/questions/511658/sublime-text-2-open-file-from-find-results-keyboard-shortcut – jasonleonhard Dec 11 '14 at 18:00
6 Answers
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.
-
1
-
1Thanks! 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. – Ivan Dec 11 '13 at 17:12
-
4
-
5`
` was a very nice trick!... Thank's for that. Also, (in case someone doesn't know and need it) you can define ` – gmo Mar 11 '15 at 16:05`, ` `, filters... or mix them with a `comma`. -
-
1Instead of double-clicking on a line, is there a keyboard shortcut? – soundly_typed May 29 '15 at 22:34
-
2@mindeavor You can cycle through the results using F4 (forward) and shift+F4 (backwards) on Windows. See the `Find --> Find Results` tab. – keyser May 29 '15 at 22:47
-
1@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 – soundly_typed May 30 '15 at 00:46
-
What 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. – Jim Hall Oct 19 '15 at 15:04
-
Thank you so much for the
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 – Giancarlo Gomez Jan 21 '16 at 19:08instead made it search FAST as hell again!!! -
@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! – Labanino May 29 '16 at 13:14
-
⇧ means `Shift`. (I am such a fool to regard `⇧` as `up` in the very beginning) – ch271828n Jun 06 '16 at 07:00
-
-
-
@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 with `Test` – keyser Aug 31 '16 at 18:40
-
-
It doesn't work. When I input `Where`(folder path on my mac) and `File`, it returns empty immediately, even that folder has thousand of files. – Stiger Jul 15 '19 at 07:20
-
Too bad there are not placeholders, it would be cool to do `
/sub/path` :'( – Elouan Keryell-Even Jul 30 '19 at 08:38 -
would it be difficult to select a folder in the left panel and press `ctrl+shift+F` and have that folder automatically added to the `Where` field in the search (as jetbrain did) – medmek Apr 15 '21 at 22:57
-
would it be difficult to select a folder in the left panel and press `ctrl+shift+F` and have that folder automatically added to the `Where` field in the search (as jetbrain did) – medmek Apr 15 '21 at 22:57
-
I 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 (with `node_modules` excluded) now it only searches in 760 files. Any ideas why this is the case? Not excluding `node_modules` makes it 2650 files searched now. – Jonathan Rys Jun 10 '21 at 17:38
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.

- 2,132
- 1
- 24
- 25
-
1This is the way.... it does recursive search in the project. Only specifying folder does not work. Thanks! – WesternGun Jan 11 '18 at 16:45
-
-
@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? – hello_there_andy Nov 13 '19 at 18:28
-
1@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 :) – WesternGun Nov 14 '19 at 09:59
-
@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 – hello_there_andy Nov 14 '19 at 13:33
-
In my PC 20 levels seems to be the upper limit for now. Maybe reducing some levels? It now is off-topic. – WesternGun Nov 14 '19 at 14:28
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.

- 4,765
- 8
- 40
- 57

- 19,560
- 31
- 97
- 141
[![enter image description here][1]][1]
Its Easy, But Sometimes when it dont works it create a havoc. Steps Mentioned: [1]: https://i.stack.imgur.com/gYrMu.jpg
- Cntr/Cmd+Shift+F ,
- From First row Select Context and buffer
- UseGitignore, make sure, by default "Open Files and Folder" writen in where clause
- Find and enjoy

- 403
- 5
- 8