Find and replace in a selection in Google Docs, and what to do when Find and replace isn't working
Google Docs' Find and replace always works on the whole document: there is no "selection only" or "in selected text" option. Google's help page for the feature (checked 1 November 2026) lists only two options for documents: "Match case: Matches only words with the same capitalization" and "Match using regular expressions: In Google Docs, matches words based on regular expressions." Replace all therefore changes every match, including the ones in parts you wanted to leave alone. Below: five ways to replace inside one part of a document, then a table of fixes for when Find and replace finds nothing or the wrong thing.
Replace inside one part of a document: five ways
1. Step through with Next and Replace (few matches, no setup)
Open Edit > Find and replace (Ctrl+H, or ⌘+Shift+H on a Mac), type the word, and click Next until you reach the first match inside your part. Click Replace (not Replace all) for each match you want to change and Next to skip the others. Fine for a handful of matches; slow for fifty.
2. Move the part to a new document, replace all there, move it back
- Select the part and cut it (Ctrl+X).
- Open a new document (type
docs.newin the address bar) and paste (Ctrl+V). - Run Find and replace with Replace all in the new document: every match there is inside your part.
- Select all (Ctrl+A), cut, go back and paste where the part was.
Pasting between Google Docs keeps bold, links, headings and lists. Comments and suggestions on that part do not travel with it, so resolve them first.
3. A Google Sheet, for plain-text lists
If the part is a list (names, references, one item per line), paste it into column A of a Google Sheet. In Sheets, select only the cells you want, open Edit > Find and replace and set Search to "Specific range": Sheets can limit a replace to a range, and it also accepts regular expressions with $1 in Replace with (see our regex guide). Copy the column back into the document. Formatting inside the text (bold words, links) is lost on the way.
Several words to change in that part, not one: copy the part out as plain text into our free bulk find and replace tool, paste your list of find -> replace pairs, check the matches per pair, replace all and paste back (plain text, so bold and links are lost).
4. Apps Script: a "Replace in selection" menu in your document
This adds a menu to the document that replaces only inside the text you have selected. Open Extensions > Apps Script, delete the sample code, paste the script below, click Save, then reload the document. A Selection tools menu appears next to Help. Select text, choose Selection tools > Replace in selection, type what to find and what to replace it with. The first run asks you to allow access to the document.
// Replace plain text (not regex) only inside the current selection.
// Matching is case-sensitive, like Docs with "Match case" ticked.
function onOpen() {
DocumentApp.getUi().createMenu('Selection tools')
.addItem('Replace in selection', 'replaceInSelectionPrompt')
.addToUi();
}
function replaceInSelectionPrompt() {
var ui = DocumentApp.getUi();
var f = ui.prompt('Replace in selection', 'Find:', ui.ButtonSet.OK_CANCEL);
if (f.getSelectedButton() !== ui.Button.OK || !f.getResponseText()) return;
var r = ui.prompt('Replace in selection', 'Replace with:', ui.ButtonSet.OK_CANCEL);
if (r.getSelectedButton() !== ui.Button.OK) return;
var n = replaceInSelection(f.getResponseText(), r.getResponseText());
ui.alert(n + ' replaced in the selection.');
}
function replaceInSelection(find, replaceWith) {
var sel = DocumentApp.getActiveDocument().getSelection();
if (!sel) throw new Error('Select some text first (a blinking cursor is not a selection).');
var T = DocumentApp.ElementType;
var count = 0;
sel.getRangeElements().forEach(function (re) {
var el = re.getElement(), type = el.getType();
if (type !== T.TEXT && type !== T.PARAGRAPH && type !== T.LIST_ITEM) return;
var text = el.editAsText(), s = text.getText();
var from = 0, to = s.length - 1;
if (re.isPartial()) { from = re.getStartOffset(); to = re.getEndOffsetInclusive(); }
var hits = [];
for (var at = s.indexOf(find, from); at !== -1 && at + find.length - 1 <= to;
at = s.indexOf(find, at + find.length)) hits.push(at);
for (var i = hits.length - 1; i >= 0; i--) { // back to front keeps offsets valid
var end = hits[i] + find.length - 1;
if (replaceWith) text.insertText(end + 1, replaceWith);
text.deleteText(hits[i], end);
count++;
}
});
return count;
}
Only the matched characters change, so the rest of the selection keeps its formatting; the new text takes the formatting of the character before it. Limits: a match must lie fully inside the selection, and a match that runs across an inline image, smart chip or equation is not found. Tables are covered when you select text inside the cells; a selection that starts outside a table and ends inside it skips the table. Run it on a copy (File > Make a copy) the first time.
Tested on 1 November 2026 with node against a small mock of DocumentApp: a partial selection inside one paragraph, a selection across three paragraphs, matches just outside the selection left alone, an empty replacement, a replacement that contains the search word, no selection, and the menu prompts. Not yet run in a live Google Doc; tell us at replacekit@tuper.app if it behaves differently.
5. ReplaceKit: "Selection only" checkbox (add-on, not listed yet)
ReplaceKit is a Google Docs add-on we are building. Its sidebar has a Selection only checkbox: tick it and every match outside the text you selected is ignored, with a preview list of the matches before you replace. It works together with match case, whole word, regular expressions with $1, and \n for line and paragraph breaks. Selection only is in the free version, with no click limit or trial. Pro ($6/month or $48/year) adds bulk lists of find => replace pairs, replace with formatting and saved rule sets. It is not in the Google Workspace Marketplace yet, so you cannot install it today.
Find and replace not working in Google Docs: causes and fixes
| What you see | Likely cause | Fix |
|---|---|---|
| "Smith" is found but "SMITH" or "smith" is not | Match case is ticked | Untick Match case, or run a second pass for each spelling. |
0 results for text that is clearly there, e.g. $5.00, (draft), a+b, v1.2? | Match using regular expressions is ticked, so $ . ( ) + ? * [ ] have special meanings | Untick the regex box, or put a backslash before each such character: \$5\.00, \(draft\). |
Words with an apostrophe or quotes are missed (don't, "Acme") | The document may use curly quotes (Tools > Preferences > Use smart quotes turns ' into ’ as you type) while you typed straight ones in Find | Copy the quote character from the document into Find, or tick regex and use don['’]t. Do it on pasted text: turn curly quotes into straight ones before you paste. |
| Text in a header, footer or footnote is not changed | Find and replace works on the main text of the document | Click into the header, footer or footnote and edit it there, or use a tool that searches them (ReplaceKit has Headers and Footnotes checkboxes). |
| Replace all leaves crossed-out old text and coloured new text | You are in Suggesting mode, so each replacement is a suggestion | Switch to Editing with the pencil menu at the top right (needs edit access), then Replace all. With view or comment access the replace buttons can't change the document. |
| A phrase from a pasted PDF is not found | The PDF paste put a line break in the middle of the phrase | Join the broken lines first: how to remove line breaks after a PDF paste. |
| Two words with a normal space in Find aren't found | The gap in the document is a non-breaking space or a double space | Tick regex and use . for a non-breaking space (New.York) or \s+ for several spaces (New\s+York; Docs' regex flavour RE2 does not count a non-breaking space as \s), or copy the gap from the document. Do it on pasted text: replace non-breaking spaces or collapse double spaces. |
\n, $1 or ^p in Replace with shows up as literal text | Docs can't insert line breaks or capture groups through Replace with | See line breaks in find and replace and capture groups in Docs. |
| Text inside a drawing, chart or image is not found | That text is not part of the document's text | Edit the drawing (double-click it) or the source chart in Sheets. |
On a long document Replace all can take a while and the page may stop responding for a moment; wait for it rather than clicking again. Undo (Ctrl+Z) reverses a Replace all.
ReplaceKit is built and in testing. It is not in the Google Workspace Marketplace yet. Leave your email and we send one message when you can install it.
The free version will have no click limit or trial clock.
More ReplaceKit guides
- Find and replace with a line break or paragraph break in Google Docs
- How to remove line breaks in Google Docs (PDF paste fix)
- Find and replace formatting in Google Docs (bold, colour, highlight)
- Regex find and replace in Google Docs: capture groups and wildcards
- Free online tool: remove line breaks from any text (runs in your browser)
Sources
- Google Docs Editors Help: Search and use find and replace (checked 1 Nov 2026: the only document options are "Match case: Matches only words with the same capitalization" and "Match using regular expressions: In Google Docs, matches words based on regular expressions"; no selection-only option; Sheets' Find and replace has its own options and a search range)
- Apps Script reference: Document.getSelection, RangeElement (isPartial, getStartOffset, getEndOffsetInclusive) and Ui (createMenu, prompt, alert)