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
- Open global search with
Ctrl+Shift+F(orCmd+Shift+F). - Type your search term in the top input box.
- Expand the replace field and enter the replacement text.
- Use the icons to toggle regex, case sensitivity, and whole word matching.
- Click "Replace All" or replace individual matches one by one.
Tips
- Use
files.excludesettings to hide generated files from search results. - Regex capture groups like
$1work 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.