How to find and replace text on Mac
You can do this with Note My. Here is where the controls are, what each option changes, and what the app is telling you when it beeps instead of replacing.
Find and replace is the least glamorous thing a text editor does and the one people most often get wrong. A stray match inside a longer word, a replacement that ran across a file you were not looking at, a count that quietly stopped being accurate. This guide covers where the controls live in Note My, what each one changes, and how to see exactly what a query has matched before you commit to it.
Everything here happens on your Mac. Nothing you search for or replace is uploaded, there is no account, and your files never leave the machine.
Where Find and Replace lives
It is a toolbar button, not a bar that slides down over your text. Look for the magnifying glass over a line of text, between the Compare menu and Go to Line. It is drawn as a bezeled button with no chevron, and its tooltip reads "Find and replace in the active tab." Click it and a pop-over appears, anchored to the button. Inside it you get:
- a find field, which searches as you type;
- a replace field;
- a scope control labelled This File / All Tabs;
- three checkboxes — Case Sensitive, Whole Word, Regular Expression;
- a status label carrying the live match count;
- seven buttons: Find Next, Find Previous, Find All, Bookmark All, Replace, Replace All, Replace in All Files.
Clicking anywhere outside the pop-over dismisses it, and so does ⎋ — and dismissing it clears the match highlights from the document. That is worth knowing before you close it to go and look at something.
The toolbar button and the system find bar
Two find controls, two behaviours. The toolbar button opens the Find and Replace pop-over — the one with the scope control, the live count and the seven buttons. ⌘F raises the macOS find bar, a separate control with its own field. When you mean to replace something, reach for the toolbar button.
The Edit menu's find commands all belong to the macOS find bar: ⌘F opens it, ⌥⌘F opens its own replace variant, ⌘G and ⇧⌘G step to the next and previous match in it, and ⌘E loads the selection into its field. They are fine for a quick look, and they are the keys you already know from every other Mac app. The toolbar button is where the fuller set waits: the This File / All Tabs scope, the live match count, Bookmark All and Replace in All Files. Reach for it whenever the search is going to end in a change.
Replace text in one file
-
Open the pop-over
Click the magnifying-glass button in the toolbar. It acts on the active tab, so make sure the file you mean is the one in front.
-
Leave the scope on This File
The segmented control offers This File and All Tabs. For a single-file edit, This File keeps the count, the highlights and the stepping confined to the document in front of you.
-
Type what you are looking for
Our find and replace searches as you type. Every match in scope highlights, and the status label keeps a running count. Watch that number: it warns you a query is too broad before you touch a replace button.
-
Narrow it with the three options
Turn on Whole Word if your query lives inside longer words. Turn on Case Sensitive if the difference between
Valueandvaluematters. Leave Regular Expression off unless you mean it. -
Step through the matches to check them
Press ↩ in the find field to move to the next match and ⇧↩ to move back; Find Next and Find Previous do the same. This is the step most people skip, and the one that catches a bad match before it is made permanent.
-
Type the replacement
Fill in the replace field. With Regular Expression on, the replacement is a template, so
$1inserts a captured group. With it off, the text is inserted literally. -
Replace one, then replace the rest
Replace changes the current match only. Replace All changes every match in scope at once. The live count is your preview: if it says 3 and you expected 40, stop and fix the query before pressing anything.
-
Save
⌘S. Until you do, the tab title carries a leading asterisk marking unsaved work, and our auto-recovery safety net holds the edit for you, so an unexpected quit does not cost you the sweep. Saving is what puts it on disk.
What each button does
| Button | What it does |
|---|---|
| Find Next | Moves the selection to the next match. Same as ↩ in the find field. |
| Find Previous | Moves to the previous match. Same as ⇧↩. |
| Find All | Acts on every match in the chosen scope at once, rather than stepping the selection to one of them. |
| Bookmark All | Marks every match, so the lines carrying them can be navigated from the gutter afterwards. |
| Replace | Replaces the current match only. |
| Replace All | Replaces every match at once, in whatever scope is selected. |
| Replace in All Files | Sweeps every open tab in one press. See the note below. |
Replace in All Files sweeps the tabs you have open, and it shows you the whole run: you watch it move through them — a yellow pulse, the edit, a green pulse — and it leaves you back on the tab you started from. Every tab it touched now carries unsaved changes, so nothing reaches the disk until you save it and you can undo any tab you are unhappy with. It also switches the scope control to All Tabs and leaves it there, so glance at the scope before your next search.
Case Sensitive, Whole Word and Regular Expression
The three checkboxes narrow the same search and combine freely. Between them they account for most of the replaces people regret.
Case Sensitive
With it off, capitalisation is ignored, so Error and ERROR match a query typed in lower case. Turn it on and Error stops matching error. The replacement is inserted exactly as you typed it either way, so what lands in the document is always what you can see in the replace field. When a file mixes casing and you want both forms kept, run two passes with this option on — one for Error, one for error — and each pass puts its own replacement in place.
Whole Word
Matches your query only where it stands as a word of its own. With it on, searching for cat will not match inside category or concatenate. It is the option worth reaching for first when a replace-all looks frightening.
Regular Expression
With it off, every character is searched for exactly as typed, so ., *, ( and the rest are just those characters, with nothing to escape by hand. With it on, your query is read as a pattern and the replacement becomes a template, so $1 inserts the first capture group. An invalid pattern gives you "Invalid pattern: …" and a beep, rather than a sweep you did not intend.
Searching every open tab
Switch the scope to All Tabs and the search, the highlighting and the count cover every document you have open. It is the right tool for a rename spanning a handful of files you have already opened.
To reach past the tabs and out across a directory tree, use Search ▸ Find in Folder… (⇧⌘F). It looks through every text file under a folder you choose and lists what it finds grouped by file, and a double-click opens any result at the right line. It only ever reads the files it searches, so pointing it at a whole project can never alter one of them. That makes a tidy first pass on a large job: survey the folder, open the files that matter as tabs, then switch the scope to All Tabs and sweep them together, with every change sitting unsaved in front of you until you commit it.
Recent searches
The find field remembers your recent queries; pick one from the field's own menu rather than retyping a long regular expression you got right an hour ago. When the list is empty it reads "No recent searches", and a Clear Recent Searches item sits at the bottom for when you would rather it did not remember.
What the status label is telling you
| What you see or hear | What it means |
|---|---|
| A running count | The normal state. It updates as you type and reflects the current scope and options. |
| "No matches", plus a beep when you step or replace | Nothing matched. The beep is deliberate: the app would rather tell you it did nothing than do nothing silently. |
| "Invalid pattern: …", plus a beep | Regular Expression is on and the query is not a valid pattern. Nothing was searched and nothing was changed. |
| "(capped — narrow your query for full count)" | Your query is matching an enormous number of times, and the label says so plainly rather than showing a figure you could not rely on. Searching and stepping through the matches carry on as normal, and narrowing the query brings the exact number straight back. |
Other ways to find text in a file
- Double-click an identifier. Every occurrence highlights across the document, matched as a whole word. No pop-over needed for "where else is this used?".
- The Occ counter in the status bar answers for the word you have selected. Double-click a word and the figure arrives at once, which is the quickest way to size a rename up before you open the pop-over at all. For anything longer than a single word, the pop-over's live count is the one to read.
- Count Matches, in the Search menu, reports "N matches on M lines." Run your search first and leave the highlights in place, then ask for the count.
- Bookmarks. After Bookmark All, F2 and ⇧F2 step between marked lines and ⌘F2 toggles one by hand. The bookmark menu also offers Copy Bookmarked Lines and Delete Bookmarked Lines — the latter being how you strip every line containing a query.
- Go to Line (⌘L) when you already know where you are heading. A number past the end of the file is refused outright, rather than dropping you on the last line and letting you think you arrived.
Troubleshooting
A different find bar appeared
What ⌘F raises is the macOS find bar, the same lightweight control you get in most Mac apps, and it is perfectly good for a quick look at a word. The Find and Replace pop-over — with the This File / All Tabs scope, the live count and the seven buttons — opens from the magnifying-glass button in the toolbar, anchored right where you click.
The Mac beeps and nothing happens
Two causes. Either there were no matches to step to or replace, and the label reads "No matches"; or Regular Expression is on and your query is not a valid pattern, and the label starts with "Invalid pattern:". Either way the document was left alone.
The count says "capped"
Your query is matching an enormous number of times, so the label tells you plainly rather than presenting a rounded figure as though it were exact. Add Whole Word, add Case Sensitive, or make the query longer, and the number comes back. Searching and stepping through the matches carry on as normal while you tighten it. It is a prompt worth taking, because a query that wide is almost always wider than you intended, and a sharper one is both easier to check and quicker to work with. Get the count down to a figure you recognise before you press a replace button.
Replace All caught more than I meant
Almost always Whole Word being off, or a query short enough to appear inside longer words. Undo with ⌘Z, turn the option on, and check the count before pressing the button again. Nothing was written to disk unless you saved, so the file on disk is still the one you started with.
My other open files changed
You pressed Replace in All Files, or the scope was set to All Tabs — both sweep every tab you have open, which is exactly what you want when a rename spans several documents. Nothing on disk changed until you saved, so a tab you would rather leave as it was can be undone with ⌘Z or closed without saving.
The highlights vanished
Closing the pop-over clears them, by design. Reopen it and run the query again — your recent searches are waiting in the find field's own menu, so it is a pick rather than a retype. If you will need the positions later, Bookmark All first and navigate from the gutter instead.
Getting more out of a sweep
Once the pop-over is familiar, most of its value comes from combining it with the things sitting next to it. A few routines worth having in hand:
- Rename across the files you have open. Bring the documents that need the change up as tabs, set the scope to All Tabs, turn on Whole Word, and one Replace All carries the rename through every one of them. Nothing reaches the disk until you save, so you can read each tab over before committing it.
- Reshape lines with a pattern. With Regular Expression on, the replace field takes a template, so a group you capture in the query comes back as
$1in the replacement. That is how you move a date from the end of a line to the front, or turn a loose column into a tidy list, without touching the lines one at a time. - Strip every line that matches. Run the query, press Bookmark All, then choose Search ▸ Delete Bookmarked Lines. Debugging output, empty comment rows and a stray block of test data all go in a single move, and a confirmation stands between you and the delete.
- Collect matches instead of changing them. Bookmark All followed by Search ▸ Copy Bookmarked Lines lifts every matching line onto the clipboard, ready to paste into a new tab as a summary of what the file actually contains. The document you took them from is left exactly as it was.
- Check your work with a count. Count Matches reports "N matches on M lines", so you can take a figure before the sweep and another after it, and see that the two agree.
- Record the routine once. Find next, find previous and replace are among the actions our macro recorder plays back, so a sweep you know you will run again on tomorrow's file is captured once and repeated with a keystroke.
- It all stays on your Mac. Your query, your replacement and your files never leave the machine. Nothing is uploaded, there is no account and no sign-in, and the only record of what you searched for is the recent-search list you can clear yourself.
Frequently asked questions
How do I open Find and Replace on a Mac?
Click the magnifying-glass button in the Note My toolbar, between the Compare menu and Go to Line. The pop-over opens anchored to it, carrying the find and replace fields, the This File / All Tabs scope, the three options, the live match count and the seven buttons. ⌘F raises the macOS find bar instead, a lighter control that is handy for a quick look at a word.
What does "Replace in All Files" act on?
The tabs you currently have open, which is what turns a rename spanning several documents into a single press. Each tab it edits becomes a document with unsaved changes, marked with a leading asterisk, and nothing reaches the disk until you save it — so you get to read the result over before any of it is permanent.
Can I use capture groups in the replacement?
Yes, when Regular Expression is on. The replace field then takes a template, so $1 inserts the first capture group, $2 the second, and so on. With the option off, the replacement text is inserted literally.
How do I search a whole folder rather than a file?
Use Search ▸ Find in Folder… (⇧⌘F). It searches every text file under a folder, lists the matches grouped by file, and opens any result at the right line on double-click. From there, open the files you want to change as tabs, set the pop-over's scope to All Tabs, and replace across them together.
Why does my search find matches inside longer words?
Because Whole Word is off. With it on, your query matches only where it stands as a word of its own, so a search for id stops matching inside identifier and void.
Does anything I search for leave my Mac?
Everything happens on your Mac. There is no account and no sign-in, nothing is uploaded, and there is no tracking or telemetry of any kind — so a query typed against a file full of customer data stays as private as the file itself. The only record kept is the recent-search list in the find field, which you can empty yourself with Clear Recent Searches.
Can a find and replace be recorded as a macro?
Yes. Find next, find previous and replace are among the actions our macro recorder will repeat for you, along with typing, paste, navigation, selection, Go to Line, save and bookmarks. A playback counts as one step, so a single ⌘Z reverses the whole run.