4. Workspace & Global Search

When working in standard, small projects, finding code is straightforward. However, inside massive monorepos or enterprise projects, code is distributed across hundreds of folders. VS Code contains a fast, multi-threaded **Global Search Engine** to track down variables or execute bulk updates.

Launching Global Search

Open the search sidebar pane instantly from your keyboard using the following shortcuts:

PlatformShortcut Key
Windows / LinuxCtrl + Shift + F
macOSCmd + Shift + F

Filtering Files (Files to Include/Exclude)

Often, search results are cluttered by build outputs (like node_modules, dist, or build directories). You can filter files by clicking the three dots (`...`) below the search fields:

  • files to include: Enter search boundaries, e.g. typing *.js limits searches strictly to Javascript files, or typing src/components/ restricts results to the components folder.
  • files to exclude: Enter exclusions, e.g. typing **/test/** ignores all test files.

Advanced Search: Case Sensitivity & Regex

Make your searches extremely precise using the three toggle icons inside the search input bar:

  1. Match Case (Icon `Aa`): Limits results strictly to case-specific characters. (Shortcut: Alt + C / Option + C).
  2. Match Whole Word (Icon `[ab]`): Excludes words where your term is just a substring. E.g. searching for `port` will not return `transport` or `viewport`. (Shortcut: Alt + W).
  3. Use Regular Expression (Icon `.*`): Enables full regex search syntax! (Shortcut: Alt + R).
    • Example: Searching for const \w+Controller finds all controller variable declarations.
    • Example: Searching for <h[1-6]> matches all HTML headings.

Global Search and Replace

To rename a variable, class name, or update URLs across 50 different files at once, use **Global Replace**:

  1. Press Ctrl + Shift + H (Cmd + Shift + H on macOS) to open the search and replace input fields.
  2. Type your search query, then type the new replacement text in the second row.
  3. VS Code will display a visual diff panel for every file showing exactly what will change.
  4. Click the **Replace All** button next to the replacement bar (or press Ctrl + Alt + Enter / Cmd + Alt + Enter) to commit changes across all files instantly!
Exclusion Best Practice: Save constant exclusions globally so you don't have to type them on every search. Go to Settings (Ctrl + ,), search for search.exclude, and add common build outputs or temporary log folders to the ignore list!