How to highlight all occurrences of a word on Mac
You can do this with Note My with a double-click. Every other use of that word is marked down the length of the file, and the status bar tells you how many there are.
You are about to rename a variable, delete a helper, or change what a constant means, and the first question is always the same: where else is this used? Scrolling does not answer it, and neither does a search that also matches the word inside three longer words. You want every real use of that identifier to light up at once, in place, without changing a character of the file.
In Note My that is one double-click. This guide covers what the double-click does, the matching rules it applies, the separate status-bar counter that tells you how many matches there are, and how our find and replace carries the same question further when you want to count, step through or act on what you find.
None of this touches your document. Highlighting is something you look at, not something the file keeps: a file with every occurrence marked is byte-for-byte the file you opened.
Highlight every use of an identifier
-
Double-click the word
Double-click anywhere inside the identifier you care about. The selection snaps outwards to the whole identifier — you do not have to hit it precisely — and every other occurrence of it in the document is highlighted. The marks run the whole length of the file, not only the part on screen, so what you scroll past is the full picture rather than a sample of it.
Make this move before you rename anything: the marks show the size of the change in place, beside the code that gives each use its meaning.
total + tax = grand sum(total, fees) avg(total, count)14 occurrences highlightedDouble-click an identifier and every other use of it lights up, with a live count in the status bar. The match is whole-identifier and Unicode-aware, so totalnever matches insidesubtotal. -
Read the count in the status bar
The status bar carries six counters: Chars, Words, Spaces, Lines, Sel and Occ. Occ answers "how many?", and it fills in as soon as the double-click lands. Two uses means a definition and one caller; forty means you want a plan before you start editing.
Chars 2 411 908 Words 318 442 Spaces 402 117 Lines 51 204 Sel 0 Occ 0 ✓ Clean ↵ LF Aa UTF-8 {} Plain Text ⌘ IdentifySix counters, live: characters, words, spaces, lines, the size of the selection, and how many times the selected word occurs. They are cached on the document, so a keystroke does not recount two million characters. -
Scroll through the marks
The marks stay put on the lines you pass, so you can read at your own pace. Nothing here counts as an edit: the tab picks up no unsaved changes, and there is nothing to undo.
-
Clear the highlights
Double-click somewhere that is not an identifier — whitespace, or punctuation that is not a bracket. A double-click that lands on no identifier clears the highlighting rather than leaving it behind. Avoid a brace, a parenthesis or a square bracket: a double-click there folds the block instead.
Whole identifiers only
This is the difference between occurrence highlighting and a plain substring search, and it is what makes a double-click worth trusting on unfamiliar code.
A match only counts when the characters either side of the word are not letters, digits or underscores. Double-clicking id does not light up identifier, valid, id_token or userId. You get the uses of the name, not the appearances of the letters — a list you can act on rather than one you have to filter by eye.
Identifiers written in any script are treated the same way. Accented, Greek, Cyrillic and CJK characters count as part of the word rather than as the edge of it, so a name is never cut in half and matched on the fragment. A variable called précision matches précision and not précisionMax.
| Text in the file | Highlighted? |
|---|---|
total | Yes |
total), (total, total, | Yes — punctuation is a boundary |
subtotal, totals, total_rows | No — the neighbouring character is a word character |
TOTAL | No — the match is exact; our find and replace carries a case option for when you want one |
"total" inside a string literal | Yes — a use inside a string or a comment counts like any other |
That last row matters. Matching goes by the word itself: a local index in one function, an unrelated index in another and the word index in a comment are all marked, so nothing is quietly left out of the picture. That is what you want when you are weighing up a rename. You see every place the name appears, in the order it appears, with the surrounding code right there to read each one against.
What the Occ counter counts
The pill and the highlighting look like one thing, and most of the time they move together. They answer to different actions, though, and knowing which is which gives you a second way to ask the question.
Highlighting follows the double-click. The Occ counter follows your selection — any selection, including one you dragged out or extended with the keyboard. It counts on two conditions:
- It counts plain words. Letters, digits and underscores — exactly the shape of an identifier. Double-click a bare name, or drag across one, and the number lands with the selection.
- It is tuned to names rather than paragraphs. Select something the length of a name and the count answers straight away, however long the document behind it is.
Select a name and the total arrives with it; move the selection to the next name and the number follows you to that one. This is worth doing deliberately before a refactor. Step along a line of arguments, one name at a time, and you learn which of them are local and which are threaded through the rest of the file — a picture of the whole file for one gesture per name, and no edit made to get it.
For a phrase, a partial word, or anything with punctuation in it, our find and replace counts whatever you type into it and keeps the total live as you sharpen the query. Between the two you have a number for every kind of thing you might want to count: Occ for the name under the cursor, Find for everything else.
Your file stays exactly as it was
The marks are something you see, not something the file records. The file on disk is unchanged, the tab is not marked as having unsaved changes, there is no undo step, and nothing you can do with occurrence highlighting can alter a byte.
The same goes for where the work happens. Every match is worked out on your Mac: nothing is uploaded, there is no account, and the file never leaves the machine — which makes this safe on a client's source or anything else confidential.
Working in very large files
A log dump, a database export or a generated data file is where a lot of editors stop being pleasant to use. Our large-file engine takes documents like those in its stride: the window is usable straight away, scrolling stays smooth from the first line to the last, and you can read and search a heavy file rather than sit waiting on it. With a document that size open, the status bar marks it as a large file — a note for information, with nothing to click and nothing you need to do about it.
Our find and replace is the instrument that suits a file that size, and it scales with it. The match count updates live as you type, Whole Word applies the same whole-word rule described above, and everything it finds can be bookmarked, stepped through or replaced.
| What you want | How to get it |
|---|---|
| Every line that mentions a name, in a file of any size | Find & Replace with Whole Word switched on. The same matching rule as the double-click, with a running count beside it. |
| One number for the whole document | The live match total in Find & Replace, or Search ▸ Count Matches for the phrasing "N matches on M lines." |
| To walk the file hit by hit | Bookmark All, then F2 and ⇧F2 to move forward and back through the marked lines. |
| Speed, above all | Nothing to set. Our large-file engine keeps the window responsive on its own, and reading a very long file feels the same as reading a short one. |
The size of the document changes nothing about where the work happens, either. A very long log is read on your Mac in exactly the way a twelve-line script is, which is what makes this a reasonable place to open an export you would rather not hand to anybody.
Carrying the question further
Occurrence highlighting is a glance: it answers "where is this used" in the time it takes to double-click. When the answer raises a bigger question — count them, step between them, match them loosely, look outside this file — the rest of the search tools pick the question up from there.
| What you want | Use |
|---|---|
| See every use, right now, in place | Double-click the identifier |
| A count, case-insensitive matching, or a regular expression | Find & Replace, from the magnifying-glass button in the toolbar. Its options are Case Sensitive, Whole Word and Regular Expression, scoped to This File or All Tabs. |
| A marker beside each match, so you can step between them | Bookmark All in the Find popover, or Search ▸ Bookmark All Search Matches (⌥⌘B). Then F2 and ⇧F2 step forward and back. |
| The number of matches and the lines they fall on | Search ▸ Count Matches. It reports on the find you have already run — "N matches on M lines." — so run the find first, then ask for the count. |
| Every use across a whole project folder | Search ▸ Find in Folder… (⇧⌘F). Results are grouped by file; double-click one to open at that line. |
Open our find and replace from the magnifying-glass button in the toolbar — that button is the way in. ⌘F opens the system find bar, which is a separate control with its own behaviour, so reach for the toolbar when you want the options described here.
Searching a big file for a very common word behaves exactly as it does in a short script: you step between matches, bookmark them and replace them in the usual way. The running total is candid with you while you do it. When a query matches an enormous number of times the status label reads "(capped — narrow your query for full count)" rather than quietly rounding, so you are never reading a figure that looks precise and is not. Sharpen the query and the exact number comes back.
Troubleshooting
The double-click folded a block instead of highlighting anything
You double-clicked a brace. A double-click on a character with a matching bracket — {}, () or [] — folds that block, which is a quick way to collapse a function you are scrolling past. Double-click the same brace again to unfold it, then double-click the identifier itself rather than the punctuation beside it.
The double-click did not select a word
The double-click landed where there is no identifier — whitespace, punctuation, or the interior of a folded block. Clicking inside a folded region expands it, which is the behaviour you want when you are trying to see what you folded; land the next double-click on the name itself and the marks appear.
The Occ pill says 0 but I can see other matches
Double-click the bare identifier and the count appears. The counter answers to a short selection made entirely of letters, digits and underscores — the shape of a name — so a selection carrying a dot, a bracket or a space is one to hand to our find and replace, which counts whatever you type into it.
The status bar says this document is a large file
That marker is there for information. It tells you our large-file engine has the document in hand, which is why a file of that size stays scrollable and searchable while you work in it; there is nothing to click and no setting behind it. To gather every use of a name across a document that big in one pass, reach for Find & Replace: switch on Whole Word for the same whole-word matching the double-click gives you, with a live count beside it and every hit ready to bookmark.
Matches appear in comments and strings and I only wanted code
Matching goes by the word itself, which is what makes it instant and predictable across every language you might open. When you want the marks to carry more context than an identifier boundary gives you, Find & Replace with Regular Expression turned on lets you write the pattern that says so — an assignment, a call, a name at the start of a line — and count and step through only those.
The highlights vanished when I opened Find
Find shows its own highlights, and closing the Find popover clears the highlights in the file, the occurrence marks with them. Double-click the identifier again and the marks come straight back — the same single gesture, as quick the second time as the first, and your document is untouched throughout.
From a glance to a finished rename
The double-click is the opening move in a longer piece of work, and the tools around it are shaped to carry that work through. A rename usually runs something like this.
- Survey it. Double-click the name, read the marks down the length of the file, and read Occ for the size of the job. Two matches is a minute's work. Forty is worth a plan, and you have the number before you have touched a key.
- Mark what you want to revisit. Run the same word through our find and replace, then Bookmark All from the Find popover or Search ▸ Bookmark All Search Matches (⌥⌘B). F2 and ⇧F2 then walk you forward and back through the marked lines at your own pace, so you can read each use in context and decide about it before anything changes.
- Widen it. Search ▸ Find in Folder… (⇧⌘F) takes the same word across a whole project tree and groups what it finds by file. Double-click a result to open that file at that line — and note that a folder search only ever reads what it opens.
- Make the change. Our find and replace with Whole Word switched on applies the identifier-boundary rule you have just been reading, so renaming
totalleavessubtotalandtotalsexactly where they are. Replace in All Files extends the same replacement across every tab you have open. - Check your work. Double-click the new name. The marks and the count should match the picture you started with, which is a five-second proof that nothing was left behind.
The whole loop — survey, mark, widen, replace, verify — happens in one window, on your Mac, with the file on disk untouched until the moment you save.
Frequently asked questions
Does highlighting every occurrence change my file?
Your file stays exactly as it was. The marks are shown over your text, never saved into it. The tab is not marked as having unsaved changes, there is no undo step to unwind, and what you save is what you had.
Why does the Occ counter show a different number than I expected?
Two rules explain almost every case. The counter answers to a plain word — letters, digits and underscores only — and to a short one, the length of an identifier rather than a sentence. Double-click the bare name and the number appears at once. For a phrase or anything with punctuation in it, our find and replace counts whatever you type into it.
Can I match a word without case sensitivity?
Yes. Open Find & Replace from the toolbar and leave Case Sensitive unchecked, and total, Total and TOTAL all count as the same word. Turn on Whole Word alongside it for the same identifier-boundary behaviour the double-click gives you, and a live total of everything it finds.
Does it work with non-English identifiers?
Yes. Accented, Greek, Cyrillic and CJK characters count as part of the identifier rather than as the edge of it, so a name in any script is matched whole.
How do I find every use of a name in a huge file?
Use Find & Replace with Whole Word switched on: the same whole-word matching, a live count, and every hit available to bookmark or replace. Our large-file engine keeps the document scrollable and searchable while you work in it, and the status bar marks a document that size so you can tell at a glance which of your open tabs is the heavy one.
Is any of this sent anywhere to be processed?
Everything on this page happens on your Mac. Nothing is uploaded, there is no account, and your files never leave the machine — which is what makes this a safe place to open a client's source, an internal export or anything else you would rather not hand to a service.