ChatGPT解决这个技术问题 Extra ChatGPT

Search in all files in a project in Sublime Text 3

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.

ctrl+shift+f, then simply select root folder in Where:

k
kenorb

You can search a directory using FindFind 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.


Can you add info about the Where box?
Thanks! 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.
Updated with info about Where box and how you can put there
<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 a comma.
@mindeavor You can cycle through the results using F4 (forward) and shift+F4 (backwards) on Windows. See the Find --> Find Results tab.
E
Efreeto

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.


This is the way.... it does recursive search in the project. Only specifying folder does not work. Thanks!
I don't see the "where:" box
@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 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, 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
L
L Y E S - C H I O U K H

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.


g
garg10may

Right click on your root folder, find in folder.

https://i.stack.imgur.com/4yLsl.png


M
Mohammad Heydari

Here's the easiest way : File -> Find in files

https://i.stack.imgur.com/XQRQU.png


It's not there (anymore)
Although it's not there anymore, it's for version 2