Search the current file or the whole workspace

Quick answer

Use editor Find for text in the current file. Use workspace search to look across files, then check the paths and filters before replacing anything.

About 2 min readDocumentation reviewed Sources
On this page
  1. Choose the search scope first
  2. Inspect matches before replacing text
  3. Check focus and exclusions
Diagram Choose the option that matches your task.

Choose the search scope first

VS Code separates Find in the editor from search across files. A setting mentioned in the open document may also appear in tests, configuration or other source files.

A local match does not prove there are no other uses. A workspace search also may exclude folders or ignored files. Read the selected search location and filters before deciding what the results mean. Changing the query alone will not fix an incorrect scope.

Inspect matches before replacing text

  1. Use a distinctive word in a small sample project. Find it in the open file, then search for it across the workspace and inspect the result paths.
  2. Decide which matches belong to the change. Documentation, generated files and tests may need different treatment. If a replacement is needed, narrow the set and review the preview before applying it. Practise with disposable files rather than trying Replace All in a production repository.

Check focus and exclusions

An editor selection, local search field and workspace results panel can each change where the next action applies. Settings, extensions and workspace structure may also affect what is found.

When the results surprise you, check those boundaries first. For a code identifier, consider language-aware Rename instead of literal text replacement. Finish when you understand the intended files and changes, rather than when you have the largest result count.

Sources and corrections

Based on the official documentation below. This is not a claim of hands-on testing.

Review details and corrections

Codex — primary-documentation and editorial review. Report a correction with the app and macOS version. Leave private document names out.

Related shortcut guides

Related articles

See shortcuts for your active Mac app.

Open the menu-bar reference with a click or your configured keyboard trigger.

Explore KeyboardShortcuts.pro