How-to · VS Code for Mac
How to find and replace across files in VS Code on Mac: shortcuts and steps
In VS Code on Mac, press ⇧⌘H to open Replace in Files, then type the text you want to find in the search box. Type the replacement in the Replace box, check the diff, then apply the change to one match, one file, or all files.
Quick answer
- Press ⇧⌘H to open Replace in Files. Press ⇧⌘F first if you only want to search.
- Open a folder in VS Code. Without a folder, search covers only the files that are open.
- Type the search text and the replacement, then read the diff before you apply anything.
- Use ⌥⌘C, ⌥⌘W, and ⌥⌘R for Match Case, Whole Word, and regular expressions.
- Commit your work first. The official docs do not confirm an undo for Replace All.
What you need
- VS Code 1.145 or later, the latest stable release as of November 2026
- A project folder open in VS Code, not a single file
- The desktop app, not vscode.dev, for the full keyboard shortcuts
- Git set up in the project, recommended before any large replace
How to Find and replace text across all files in a project in VS Code on a Mac
Open your project folder
Open the folder that holds your project, not a single file. Choose File > Open Folder, pick the folder, and click Open. Cross-file search needs a folder, so a single open file limits the search to that file.
Tip: The folder name appears at the top of the Explorer sidebar when the folder is open.
Open the Search view
⇧⌘F
Press ⇧⌘F. The Search view opens in the sidebar with the cursor in the search box. Type the text you want to find. Results group by file.
Tip: Single-click a result to open that file at the match.
Open the Replace box
⇧⌘H
Press ⇧⌘H to open Replace in Files. The Replace box sits under the search box. If it is hidden, click the small arrow at the left of the search box to expand it.
Tip: Press ⇧⌘J to show the include and exclude fields when you need them.
Set the search options
⌥⌘C
Press ⌥⌘C to turn on Match Case, ⌥⌘W for Whole Word, and ⌥⌘R for regular expressions. Each one is a toggle. Press it again to turn it off.
Tip: Check the toggles before you read the results. They change which matches appear.
Type the replacement text
Click the Replace box and type the new text. VS Code shows a diff of the changes it plans to make. Nothing in your files changes until you apply it.
Tip: If the diff shows too many matches, go back and tighten the search before you apply anything.
Read the diff
Scroll through the results and open the changed files. Check every match you plan to replace. Look for hits inside longer words, comments, strings, and links that should stay the same.
Apply the replace
Use the replace controls to apply one change, all matches in one file, or all matches across the project. Start with the smallest scope you can, then widen it once the results look right.
Tip: When you are unsure of a pattern, apply one change first. It is the fastest way to test the pattern.
Save, test, and commit
⌘S
Save the changed files with ⌘S, run your tests or build, then commit the change in Git. A clean commit gives you a way back if the replace went too far.
Find and replace across files changes the same text in every file of a project in one pass. In VS Code on Mac, it lives in the Search view. You search the folder, type the new text, read what will change, and then apply it. This guide covers the desktop app, the shortcuts that matter, and the cases where search quietly misses a file. Once you know the keys, the whole job takes less time than you expect.
Open a folder before you search
Cross-file search needs a folder. If VS Code was not opened on a folder, search only runs on the files that are open right now. That is a common reason a replace seems to miss matches. Open your project with File > Open Folder, or drag the project folder onto the VS Code icon in the Dock. The folder name then appears at the top of the Explorer sidebar.
⇧⌘H
Replace in Files on macOS in VS Code's default keybindings list
Default Keyboard Shortcuts (Visual Studio Code docs)75.9%
Of all 2025 Stack Overflow survey respondents reported using VS Code
Stack Overflow Developer Survey 2025: TechnologyVS Code find and replace shortcuts on Mac
Two shortcuts do most of the work. ⇧⌘F searches the folder, and ⇧⌘H adds the Replace box. The rest tune the search. The table lists each one from the official keybindings reference, along with what it does.
| Action | Mac shortcut | What it does |
|---|---|---|
| Find in Files | ⇧⌘F | Opens the Search view for the whole folder |
| Replace in Files | ⇧⌘H | Opens the Search view with the Replace box |
| Toggle Search Details | ⇧⌘J | Shows or hides the include and exclude fields |
| Replace in one file | ⌥⌘F | Opens find and replace in the open editor |
| Match Case | ⌥⌘C | Matches upper and lower case exactly |
| Whole Word | ⌥⌘W | Matches complete words only |
| Regular expressions | ⌥⌘R | Reads the search box as a pattern |
Notice that ⌥⌘F works on one file. It opens find and replace inside the editor you have open. For a change across the project, stay in the Search view with ⇧⌘H. The two look alike, so check which one you pressed before you type.
Preview the replace before you apply it
The Replace box is where you slow down. As soon as you type replacement text, VS Code shows a diff of the changes it plans to make. Nothing in your files changes until you apply it. Use that gap to read every match.

Watch for matches inside longer words. A search for cat also hits category, and a search for id hits width when Whole Word is off. Press ⌥⌘W to turn on Whole Word, then search again and compare the results. Press ⌥⌘C too if your code treats Name and name as different words.
Narrow the search with include and exclude patterns
Press ⇧⌘J to open Toggle Search Details. Two boxes appear, files to include and files to exclude. Both take comma-separated glob patterns. A glob is a path pattern with wildcards. These patterns work well in practice:
- `src/**` limits the search to everything under the src folder.
- `**/*.test.ts` finds test files anywhere in the project.
- `/node_modules/` in the exclude box skips installed dependencies.
- `docs/**, *.lock` in the exclude box skips the docs folder and lock files.
Glob patterns are case-sensitive on Linux and case-insensitive on Windows and macOS. On your Mac, `Src/` and `src/` match the same files. Copy the path from the Explorer sidebar so you do not have to guess at the case.
Worked example: rename a function across a project
Say you want to rename `getUser` to `fetchUser` across a project. Press ⌥⌘W first, so `getUserName` stays unchanged. Then press ⇧⌘H, type `getUser` in the search box, and type `fetchUser` in the Replace box. Read the diff. If a test file uses the old name on purpose, press ⇧⌘J and exclude that file. Then apply the change to all files and run your tests. The diff is the reason to read first, because it shows what a broad match would have touched.
Use regex in VS Code find and replace
Press ⌥⌘R to turn on regular expressions. The search box then reads patterns instead of plain text. For example, `user(\d+)` finds the word user followed by digits. Put `account$1` in the Replace box, and `user42` becomes `account42`. The `$1` pulls in the first group from the search.
Turn regex off again for ordinary text. With it on, a dot matches any character, and brackets and parentheses change the meaning of your search. A search for `v1.2` with regex on also matches `v1x2`, which is rarely what you want.
Why VS Code search misses files or runs slowly
Search in VS Code runs on ripgrep, a fast search tool. It respects your ignore rules. That is why files listed in `.gitignore` do not show up in results. The docs say to keep Use Exclude Settings and Ignore Files turned on. Turning it off makes search read more files, which can slow things down and raise CPU use.
- Add `/node_modules/` to `search.exclude` in Settings.
- Keep `search.useIgnoreFiles` enabled.
- Set `search.followSymlinks` to false if a symlinked folder loops back on itself.
- Narrow the search with include patterns, then widen it once the results look right.
Each fix trades a little coverage for speed. Exclude dependency folders when you are changing your own code, and bring them back only when you need to search a library.

Common Replace in Files mistakes on Mac
- Searching with no folder open, then assuming the whole project was covered.
- Leaving regex on, then searching for a literal dot, bracket, or plus sign.
- Replacing text inside comments, strings, or URLs without reading the diff.
- Running a large Replace All with uncommitted work and no clean way back.
- Expecting a file to appear in results when `.gitignore` hides it.
Each of these is cheap to avoid and slow to fix. Read the diff, commit before a broad change, and check the scope every time.
Replace in Files on vscode.dev
VS Code for the Web runs in a browser sandbox. It has no terminal and no debugger, and only a subset of extensions run. The web docs do not say whether cross-file search covers unopened files, or whether Replace in Files works there. Use the desktop app for project-wide replaces. On the web, ⌘N opens a new window instead of a new file, and ⌘W closes the browser tab. The docs suggest ⌥⌘N and ⇧⌥⌘N as workarounds.

Where to go next
If you still need to set up the command line, read how to install the code command in VS Code on Mac. To compare two files while you replace, see how to split the editor in VS Code on Mac. The VS Code for developers page covers Git and debugging in more depth.
If you want help on screen, Lazur is a voice assistant for the Mac. Hold ⌥⌘ and ask where a control is, and Lazur points at it. For a walk through the steps, ask it to guide you one click at a time. It does not click for you. See Lazur for VS Code on Mac for what it covers.
VS Code shortcuts for this on Mac
| To do this | Press |
|---|---|
| Find in Files (open the Search view) | ⇧⌘F |
| Replace in Files (Search view with Replace box) | ⇧⌘H |
| Toggle Search Details (include and exclude fields) | ⇧⌘J |
| Replace in the current file only | ⌥⌘F |
| Toggle Match Case in the Search view | ⌥⌘C |
| Toggle Whole Word in the Search view | ⌥⌘W |
| Toggle regular expressions in the Search view | ⌥⌘R |
If it does not work
- No results for text you can see in the editor
- Check that a folder is open, not a single file. Then press ⇧⌘J and clear any include pattern that is too narrow.
- Some files are skipped
- Files listed in .gitignore are skipped while Use Exclude Settings and Ignore Files is on. Turn that toggle off for one search if you need those files, then turn it back on.
- Search is slow or the fan spins up
- Keep the exclude settings on. Add `/node_modules/` to search.exclude, keep search.useIgnoreFiles enabled, and set search.followSymlinks to false if a symlinked folder loops.
- The replace changed more than you wanted
- Restore the file from Git with `git restore path/to/file`, but only if it has no unsaved edits you need. The docs do not confirm an undo for Replace All, so keep commits small.
Faster with Lazur
Do it faster: ask Lazur while you are in VS Code
Hold ⌥ ⌘ and say what you want. Lazur sees your VS Code window. Lazur draws a circle and a label around the button or menu you need.
- 1
Hold ⌥⌘ and talk
- 2
Lazur draws a circle and a label around the button or menu you need.
- 3
You stay in VS Code. Nothing to copy into a chat window.
Free for 3 days, then $18/month. Download for Mac
You say“Where is the Replace box in VS Code?”
Lazur · points at itLazur circles the Toggle Search Details button so you can find the Replace box on screen.
Questions people ask
Does find and replace across files work without opening a folder in VS Code on Mac?
Not fully. If VS Code was not opened on a folder, cross-file search only runs on the files that are currently open. Open your project folder first, then press ⇧⌘H.
What is the shortcut for Replace in Files in VS Code on Mac?
Press ⇧⌘H, which is Shift, Command, and H. The official default keybindings list shows it for macOS. Find in Files is ⇧⌘F.
How do I replace text in one file only in VS Code on Mac?
Use ⌥⌘F. It opens find and replace inside the open editor, so the change stays in that file. Use ⇧⌘H when the change should cover the whole project.
Can I undo Replace All in VS Code on Mac?
The official docs do not say whether Replace All can be undone in one step. Commit your work in Git before a large replace, so you can restore the files if the result is wrong.
Why does VS Code skip some of my files during a search?
Search follows your ignore rules. With Use Exclude Settings and Ignore Files on, it skips anything in .gitignore and in the files.exclude and search.exclude settings. Turn that toggle off for one search if you need those files.
Does Lazur make the replacement for me?
No. Lazur does not click buttons or edit files for you. Ask it where the Replace box or the search details button is, and it circles that control on screen while you make the change.
Does VS Code 1.145 change these shortcuts?
The 1.145 release notes list no keyboard shortcut changes and no changes to Find in Files or Replace in Files. The steps on this page apply to 1.145.
How many developers use Visual Studio Code?
In the 2025 Stack Overflow Developer Survey, 75.9% of all respondents reported using Visual Studio Code. Among professional developers, the figure was 76.2%.
Sources
- Basic Editing: Find and Replace Across Files (Visual Studio Code docs) · Microsoft · checked 2026-11-09
- Default Keyboard Shortcuts (Visual Studio Code docs) · Microsoft · checked 2026-11-09
- Visual Studio Code Updates · Microsoft · checked 2026-11-09
- November 2026 (version 1.145): Visual Studio Code release notes · Microsoft · checked 2026-11-09
- Visual Studio Code for the Web · Microsoft · checked 2026-11-09
- Stack Overflow Developer Survey 2025: Technology · Stack Overflow · checked 2026-11-09
Try Lazur free for 3 days
Hold a key and ask. Lazur sees your screen, points at the button and talks you through it, in any Mac app. No credit card.