VS Code - search for text in all files in a directory

Is there a way to search for text in all files in a directory using VS Code?

Ie, if I type “find this” in my search, it will search for all files in the current directory and return files that match. Basically, as if I did grep. My colleague told me that Sublime has something like this.

+261
visual-studio visual-studio-code
Jul 25 '16 at 16:25
source share
10 answers

You can perform Editing , Search in files (or Ctrl + Shift + F - default key binding, Cmd + Shift + F on MacOS) to search in the current open folder.

There is an ellipsis in the dialog box in which you can include / exclude files, as well as options in the search box for case / word matching and using Regex.

+302
Jul 25 '16 at 21:15
source share

In VS code ...

  • Go to Explorer ( Ctrl + Shift + E )
  • Right click on your favorite folder
  • Select "Find in Folder"

The search query will be pre-populated with a track in the “include files” section.

+195
Apr 27 '17 at 7:48 on
source share

Ctrl + P (Win, Linux), Cmd + P (Mac) - Quick open, Go to file

+15
Oct. 15 '17 at 23:34 on
source share

Press Ctrl + Shift + F enter image description here

click on 3 dots below the search box.

enter your request in the search field

type ./FOLDERNAME in the files to include and press Enter

An alternative way is to right-click on a folder and select Find in Folder

+15
Jan 10 '19 at 11:05
source share

This action is not tied to the default key, to bind it, do the following:

  1. File> Preferences> Keyboard Shortcuts ( Ctrl + K , Ctrl + S )
  2. Search "find folder"
  3. Click the + icon to the left of the search result "filesExplorer.findInFolder"
  4. Enter the desired key combination
+11
Jan 09 '18 at 10:47
source share

I think this official guide should work for your case.

VS Code allows you to quickly search all files in the currently open folder. Press Ctrl + Shift + F and enter a search query. Search results are grouped into files containing the search term, indicating hits in each file and its location. Expand the file to see a preview of all hits in this file. Then click once on one of the hits to view it in the editor.

+9
Jul 25 '16 at 21:08
source share

The simple answer is to click the magnifying glass on the left side panel.

+7
Jul 18 '17 at 20:27
source share
  1. Enter Keyword Search in Search (CTRL + SHIFT + F)

  2. Exclude unnecessary folders / files using the exclusion option (!)

    example:! Folder / File *

  3. Press Enter

Search results give the desired result.

+3
Apr 22 '18 at
source share

If you have a directory open in VSCode and you want to find a subdirectory, then either:

  • ctrl - shift - F then in the files to include fields enter the path with ./ ,

or

  • ctrl - shift - E To open Explorer, right-click the directory you want to find and select the " Find in Folder... " option.
+3
Jan 24 '19 at 0:14
source share

To add to the above, if you want to search in the selected folder, right-click on the folder and click "Find in Folder" or default key binding:

Alt + Shift + F

As already mentioned, to find all the folders in your project, click "Edit"> "Find in Files" or:

Ctrl + Shift + F

+2
Jun 28 '19 at 11:40
source share



All Articles