How to Search All Files in Visual Studio Code
Finding specific text or code across a large project can be challenging, but Visual Studio Code provides a powerful global search tool to find and replace terms across your entire workspace instantly. This guide covers how to access the global search feature using keyboard shortcuts or the user interface, refine your search with filters, and use advanced tools like regular expressions to locate exactly what you need.
Opening the Global Search Tool
You can access the global search interface in VS Code using either a keyboard shortcut or the sidebar navigation.
- Keyboard Shortcut: Press
Ctrl + Shift + Fon Windows/Linux, orCmd + Shift + Fon macOS. - UI Navigation: Click on the Search icon (represented by a magnifying glass) in the Activity Bar on the left side of the window.
Once opened, a search pane will appear on the left side of your editor. Type the text you want to find into the primary input box, and VS Code will display the results in real-time, grouped by file.
Refining Your Search Results
To make your search more precise, you can toggle three options located directly inside the search input box:
- Match Case (
Aa): Restricts the search to match the exact casing of your search term. - Match Whole Word (
ab): Prevents the search from showing partial matches (e.g., searching for “log” will not return “console.log” or “logger”). - Use Regular Expression (
.*): Allows you to use regular expressions (RegEx) for complex pattern matching.
Including or Excluding Specific Files
If you want to limit your search to a specific folder or exclude
certain directories (such as node_modules or build
folders), you can use the search filters:
- Click the three dots icon (
...) directly below the search input field to expand the advanced search options. - files to include: Enter specific directories or
file extensions (e.g.,
src/to only search the source folder, or*.jsto only search JavaScript files). - files to exclude: Enter directories or patterns you
want VS Code to ignore (e.g.,
*.jsonto ignore configuration files).
Performing a Global Replace
If you need to replace a term across your entire workspace:
- Click the small arrow to the left of the Search input box to expand the Replace field.
- Type your replacement text into this second field.
- You can replace occurrences individually by clicking the replace
icon next to each result, or replace all matches at once by clicking the
Replace All icon next to the replace input field (or
pressing
Ctrl + Alt + Enteron Windows/Linux, orCmd + Alt + Enteron macOS).