Last updated: Apr 6, 2024
Reading time·4 min
If you need to search for a specific file and open it, click on the last subheading.
If you need to search for text in all files in VS Code:
Ctrl
+ Shift
+ F
.Cmd
+ Shift
+ F
.You can also show the Search view by clicking on the magnifying glass icon in the Activity bar on the left.
The results will be displayed at the bottom.
You can view the keyboard shortcut for all operating systems for the Show Search command in this table in the docs.
By default, the Search view searches for the specified text in all of the files in the current project.
You can change this behavior by setting the files to include and files to exclude fields.
I have a very thorough tutorial on how to exclude folders from a search.
Notice that there are 3 icons at the end of the field where you write the text you want to search for.
Aa
(Match Case) - enables case-sensitive search. By default, the search is
case-insensitive.ab
(Match Whole Word) - only an entire word can be matched. By default,
substrings can also be matched..*
(Use Regular Expression) - use a regular expression pattern when
searching for text.If you only need to search for text in the current file, you can use the following keyboard shortcut:
Ctrl
+ F
.Cmd
+ F
.One way to search for text only in a specific folder is to:
Ctrl
+ Shift
+ E
.Cmd
+ Shift
+ E
.There is also a keyboard shortcut that allows you to issue the Find in Folder command.
Left-click on the folder in Explorer and press:
Alt
+ Shift
+ F
Option ⌥
+ Shift
+ F
Enter
.You can also use the files to include field directly to search for text in a specific folder.
For example, setting the field to **/my-folder
only searches for text in a
directory called my-folder
regardless of whether it is a nested or a root
directory.
Similarly, src/**/include
only searches for text in an include
directory
that has an src
directory followed by zero or more directories as its parents.
If the folder is in the root directory only, you can specify it as
./my-folder
.
The search would only include the my-folder
directory, located at the root of
your project.
I've also written a detailed guide on how to exclude folders from search in VS Code.
If you need to search for a specific file in your project:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.Start typing the name of the file to filter or use the arrow keys to navigate.
Once you find the file, hit Enter
to open it.
You can start typing the name of the file to only show file names that contain the specified text.
You can also type an extension, e.g. .ts
to only show the TypeScript files in
your project.
You can view the keyboard shortcut for the command in this table in the docs.
The command is called Go to File..., Quick Open.
Things to note about the command:
.gitignore
file are not shown in the
results, depending on your configuration.The value of the Search: Use Ignore Files setting determines if files
specified in your .gitignore
file are excluded from the results.
Ctrl
+ Shift
+ P
(or Command
+ Shift
+ P
on macOS).F1
to open the Command Palette.You can also open the settings screen by pressing Ctrl
+ ,
on Windows and
Linux or Cmd
+ ,
on macOS.
The value of the Search: Use Ignore Files setting controls whether to use
.gitignore
and .ignore
files when using the Go to File command.
If you want to include files specified in your .gitignore
in the results,
uncheck the checkbox.
You can learn more about the related topics by checking out the following tutorials: