How to Search and Replace Across Files in VS Code

· Category: VS Code & Developer Tools

Short answer

VS Code's global search lets you find and replace text across all files in a workspace. It supports regex, case sensitivity, and file inclusion filters.

Steps

  1. Open global search with Ctrl+Shift+F (or Cmd+Shift+F).
  2. Type your search term in the top input box.
  3. Expand the replace field and enter the replacement text.
  4. Use the icons to toggle regex, case sensitivity, and whole word matching.
  5. Click "Replace All" or replace individual matches one by one.

Tips

  • Use files.exclude settings to hide generated files from search results.
  • Regex capture groups like $1 work in the replace field.
  • Search within a folder by right-clicking it and selecting "Find in Folder".

Common issues

  • Binary files and very large files may be skipped depending on settings.
  • Replace all cannot be undone across multiple files; use source control as a safety net.