How to search all Files in Visual Studio Code

avatar
Borislav Hadzhiev

Last updated: Apr 6, 2024
4 min

banner

# Table of Contents

  1. Search for text in all Files in VS Code
  2. Only searching for text in a specific folder
  3. Using the files to include field directly
  4. How to Search for a specific File in VS Code

If you need to search for a specific file and open it, click on the last subheading.

# Search for text in all Files in VS Code

If you need to search for text in all files in VS Code:

  1. Use a keyboard shortcut to show the Search view.
  • On Windows and Linux, press Ctrl + Shift + F.
  • On macOS, press Cmd + Shift + F.

You can also show the Search view by clicking on the magnifying glass icon in the Activity bar on the left.

click magnifying glass icon

  1. Type the text you want to search for in the Search input field.

search for text in all files

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.

three icons search

  1. Aa (Match Case) - enables case-sensitive search. By default, the search is case-insensitive.
  2. ab (Match Whole Word) - only an entire word can be matched. By default, substrings can also be matched.
  3. .* (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:

  • on Windows and Linux: Ctrl + F.
  • on macOS: Cmd + F.

only search current file

# Only searching for text in a specific folder

One way to search for text only in a specific folder is to:

  1. Show the Explorer view.
  • On Windows and Linux, press Ctrl + Shift + E.
  • on macOS, press Cmd + Shift + E.
  1. Right-click on a folder in Explorer (the left sidebar) and select Find in Folder.

select find in folder

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:

  • on Windows and Linux: Alt + Shift + F
  • on macOS: Option ⌥ + Shift + F
  1. Type in your search term and hit Enter.

search in specific folder

# Using the files to include field directly

You can also use the files to include field directly to search for text in a specific folder.

  1. Click on the three dots (ellipsis) icon below the field.

click on three dots icon

  1. set the value of the files to include field.

specify files to include

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.

# How to Search for a specific File in VS Code

If you need to search for a specific file in your project:

  1. Press:
  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.
Note: you can also press F1 to open the Command Palette.
  1. Start typing the name of the file to filter or use the arrow keys to navigate.

  2. Once you find the file, hit Enter to open it.

search for specific file

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:

  • Files that you have opened recently are shown at the top.

go to file results

  • Files that are included in your .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.

  1. Press Ctrl + Shift + P (or Command + Shift + P on macOS).
Note: you can also press F1 to open the Command Palette.
  1. Type user settings and select Preferences: Open User Settings.

open user settings

You can also open the settings screen by pressing Ctrl + , on Windows and Linux or Cmd + , on macOS.

  1. Search for search use ignore files.

search use ignore files setting

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.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.