How To Find and Replace Text

Knowing how to find and replace text can save you hours—whether you’re editing a document, cleaning up spreadsheet data, or updating code. This simple but powerful function lets you quickly locate specific words or phrases and swap them out in seconds.

From Microsoft Word to command-line tools, most platforms have built-in find-and-replace features. In this guide, you’ll learn how to use them effectively across popular software and systems.

Looking for a faster way to handle text edits and repetitive typing? TextExpander helps you automate Snippets, fix typos, and streamline your workflow even further.

Find and replace: core concepts

“Find and replace” is exactly what it sounds like. You search for a word, phrase, number, or pattern (“find”), and swap it with something else (“replace”). Most tools give you options to do this one by one or all at once.

When is find and replace useful?

Fixing repeated typos or outdated terms

Updating file names, dates, or formatting

Refactoring code or editing content in bulk

Cleaning up data in spreadsheets

You’ll also find advanced options like case matching, whole word search, and even pattern matching using regular expressions (regex). These features give you more control—and reduce the risk of replacing the wrong thing.

Want even more control over your text editing? TextExpander’s Snippets can go beyond simple replacements by inserting entire blocks of text, auto-filling dates, or applying dynamic logic.

Universal find and replace commands

Some basic find and replace commands work across nearly all applications, from word processors to web browsers. Knowing these shortcuts and features can save you time and increase your productivity.

1. Find text (search)

Windows: Ctrl + F

Mac: Command-F

These shortcuts open the Find feature in most applications, allowing you to search for specific words or phrases within a document, web page, or file.

2. Find and replace

Windows: Ctrl + H

Mac: Command-Shift-H

These shortcuts open the Find and Replace dialog, where you can both search for and replace specific text. This works in word processors like Microsoft Word, Google Docs, text editors, and even some email platforms.

3. Find next

Windows: F3 or Ctrl + G

Mac: Command-G

After initiating the find function, use these shortcuts to quickly jump to the next occurrence of your search term.

4. Replace all

Most programs allow you to quickly replace all instances of a search term at once. After opening the find and replace dialog (via Ctrl + H or Command-Shift-H), you can click Replace All to make global changes throughout the document or file.

5. Highlight search results

Windows: Ctrl + E

Mac: Command-E

In some apps, using these commands after starting a search will highlight all instances of the search term, making them easier to locate.

6. Case sensitivity and whole word

Many applications include advanced find and replace options, such as:

Match case: Ensures that only the text with the exact capitalization is found.

Whole word only: Prevents partial matches (e.g., replacing “cat” wouldn’t replace “catalog”).

These features are often found under the “More Options” or “Advanced” settings in the Find and Replace dialog.

Find and replace in word processors

Microsoft Word

Open your document.

Press Ctrl + H (Windows) or Command-Shift-H (Mac) to open the Find and Replace window.

Type the text you want to find.

Enter the replacement text.

Click Replace to go one by one, or Replace All to swap every instance.

Microsoft’s official guide offers additional details on formatting and advanced search.

Google Docs

Open your doc.

Go to Edit > Find and Replace or press Ctrl + H (Command-Shift-H on Mac).

Fill in the “Find” and “Replace with” fields.

Use Match case or Match using regular expressions (in the options dropdown).

Click Replace or Replace all.

Limitations:

Google Docs can lag with large documents.

Regex is available but limited—best for simple patterns.

For repetitive phrasing or text blocks, tools like TextExpander can automate this across Docs and beyond.

Find and replace in text editors

Notepad (Windows)

Open your file in Notepad.

Press Ctrl + H to open the Replace dialog.

Enter your search term and replacement.

Click Find Next, Replace, or Replace All.

Quick tip: This works best for basic text. No support for advanced search like regex.

TextEdit (Mac)

Open your document in TextEdit.

Use Command-F to open Find.

Click the arrow next to the search field, then choose Replace.

Type in the text to find and the replacement.

Note: TextEdit must be in plain text mode (Format > Make Plain Text) to avoid issues with formatting during replacement.

Notepad++, Sublime Text, and VS Code

These editors offer more power, especially for developers and technical users.

Common steps:

Use Ctrl + H (or Command-Option-F in Sublime on Mac).

Input find and replace terms.

Use checkboxes or options to enable:

Match case

Match whole word

Use regular expressions

Optionally, search across multiple files or folders.

Examples:

In VS Code, use Ctrl + Shift + H to replace across your entire project.

In Notepad++, enable Search Mode: Regular expression to match patterns like email addresses or date formats.

Want to automate repetitive replacements across projects or documents? TextExpander for developers can insert frequently used code snippets, saving time and reducing errors.

Find and replace in spreadsheets

Microsoft Excel

Open your worksheet.

Press Ctrl + H (or Command-H on Mac).

Enter the text you want to find and what to replace it with.

Click Options to refine your search:

Match case

Match entire cell contents

Search in formulas, values, or comments

Choose Replace or Replace All.

Caution: Excel will replace text inside formulas too—this can break calculations if you’re not careful. Always double-check before using “Replace All.”

Tip: You can also search across the entire workbook. Under “Within,” switch from Sheet to Workbook.

Here’s Microsoft’s guide for Excel Find and Replace for extra reference.

Google Sheets

Open your sheet.

Use Ctrl + H (Command-Shift-H on Mac).

Fill in “Find” and “Replace with.”

Use checkboxes for:

Match case

Match entire cell contents

Search using regular expressions

Choose to search this sheet or entire workbook.

Heads up: Like Excel, Google Sheets will replace within formulas unless you select carefully. There’s no undo for “Replace All” once changes are saved, so make a backup or use Version History to restore if needed.

Want to speed up repetitive entries or edits in spreadsheets? TextExpander snippets can quickly drop in formulas, boilerplate, or structured text.

Common mistakes to avoid

Even simple find-and-replace actions can go wrong if you’re not careful. Here are the most common pitfalls—and how to avoid them:

Replacing text in the wrong context

Find and replace is literal unless you’re using regex. Replacing “HR” might also change words like “THROUGH” if you don’t use “Match whole word.” Always review results before confirming.

Blindly using “Replace All”

It’s tempting to replace everything at once—but it’s risky. You could unintentionally change content in footnotes, formulas, or hidden sections. Always preview or step through changes first.

Replacing inside formulas or data

In Excel or Google Sheets, find and replace can modify formulas. Replacing “Jan” could break =SUM(JanuarySales). Use “Find within: values” instead of the whole sheet when needed.

Not backing up

Many tools don’t have version history or undo—especially command-line tools like sed. Always save a copy or work in a version-controlled environment.

Ignoring case or word boundaries

Not checking “Match case” or “Whole word only” can lead to partial or unintended changes. For example, replacing “no” could alter “notebook,” “north,” or “notes.”

Want to avoid manual mistakes altogether? Use TextExpander for consistent text insertion—no searching, no replacing.

Regular expressions explained

Regular expressions—commonly called regex—are patterns used to match specific combinations of characters in text. They’re supported in many find-and-replace tools like VS Code, Sublime Text, Notepad++, and even Google Docs (to a limited extent).

Regex is powerful when you need to search for patterns, not exact words. It’s ideal for:

Finding all phone numbers, email addresses, or dates

Cleaning up inconsistent formatting

Matching variable text while keeping structure

Basic regex examples

Pattern | Matches
\d+ | One or more digits (e.g., 123, 42)
\bword\b | Exact word “word” (not part of another word)
[A-Z]{3} | Three uppercase letters in a row
.+@.+\..+ | Roughly matches most email addresses
\s+ | One or more spaces or tabs

How to use regular expressions

In most tools:

Check “Use regular expressions” or “Regex mode”

Enter your pattern in the Find field

Use captured groups (e.g., \1, \2) in the Replace field to rearrange matched text

Regular expression examples

Find all dates like 03/31/2025 and convert to 2025-03-31:

Find: (\d{2})\/(\d{2})\/(\d{4})

Replace with: \3-\1-\2

⚠️ Regex is powerful but unforgiving. Test on a small section before applying to large documents.

Want a better way to insert consistent formats—no regex required? TextExpander’s date and time Snippets let you drop in perfectly formatted content with a few keystrokes.

Find and replace using command line tools

For developers or power users, command-line tools like sed, grep, and awk offer fast, flexible ways to search and replace text—especially across multiple files.

sed (Stream Editor)

sed is ideal for basic replacements in Unix/Linux or macOS terminals.

Basic syntax: sed 's/find/replace/' filename

Example: sed 's/2024/2025/g' report.txt

This replaces all instances of “2024” with “2025” in report.txt.

s = substitute

/g = global (all occurrences on each line)

In-place editing with sed:

sed -i '' 's/old/new/g' file.txt  # macOS

sed -i 's/old/new/g' file.txt     # Linux

The GNU sed manual has full documentation for complex patterns.

grep and awk

While not used directly for replacing, grep is useful to find matching lines before making changes.

Example: grep "error" *.log

This finds all lines containing “error” in .log files.

For more advanced operations, awk can process and modify structured text.

Example: awk '{gsub("old","new"); print}' file.txt

This replaces all instances of “old” with “new” and prints the modified lines.

Note: Be cautious—unintended replacements can’t be undone unless you’ve backed up files or used version control.

If you’re managing Snippets, boilerplate, or templates across codebases, TextExpander for engineers can save time with reusable, sharable content blocks.

Advanced features

Most modern editors and tools offer options beyond simple find and replace. Understanding these can help you avoid mistakes and refine your results.

Match case

Only finds text that matches the capitalization exactly.
Example: Searching for Email won’t find email unless this is unchecked.

Match whole word

Prevents partial matches. Useful when replacing a word like in, so you don’t unintentionally replace parts of words like inside or within.

Wildcards and regular expressions (regex)

Wildcards let you match flexible patterns. For example, in Microsoft Word:

b*t could match bat, bit, boat, etc.

Regex goes deeper—perfect for developers or advanced users.

Replace all 5-digit ZIP codes: \b\d{5}\b

Text editors like VS Code, Sublime Text, and Notepad++ all support regex.

Multi-file support

Some tools allow searching and replacing across multiple documents or files at once. Use this in code editors or spreadsheet apps when working with large data sets or projects.

Undo replace

Always check whether the tool supports undo after a bulk replacement. In apps like Google Docs or Word, you can use Ctrl + Z. On the command line? Not so much—backups are critical.

To avoid risky find and replace errors, TextExpander offers a safer, more predictable way to insert and update content using predefined snippets.

Conclusion

Find and replace is one of the fastest ways to edit, clean up, or update text across documents, spreadsheets, or code—but only when used carefully.

In this guide, we covered how to find and replace text in:

Word processors like Microsoft Word and Google Docs

Text editors including Notepad, TextEdit, VS Code, and more

Spreadsheets like Excel and Google Sheets

Command-line tools like sed, with mentions of grep and awk

FAQ

How do I find and replace text on my iPhone?

Finding and replacing text on an iPhone isn’t as straightforward as on desktop platforms, but you can still achieve it with a few workarounds.

For Notes or Messages:

Open the app (e.g., Notes or Messages).

Use the search bar at the top of the screen to find specific words or phrases.

Manually replace them by editing each instance, as iOS doesn’t have a built-in “replace” function for text.

For Text Editing Apps:

Some third-party text editing apps, such as Microsoft Word or Google Docs, have a find and replace feature. Here’s how to use them:

Microsoft Word:

Open your document.

Tap the search icon (magnifying glass) at the top.

Tap Find and Replace from the options.

Enter the text to find and replace.

Google Docs:

Open the document in the Google Docs app.

Tap the three dots menu in the upper-right corner.

Tap Find and Replace.

Enter the text you want to find and replace.

These apps work similarly to their desktop counterparts, but the process is less seamless on iOS due to limited built-in functionality.

For more advanced editing and replacements, consider using desktop-based solutions or tools like TextExpander, which can help streamline typing and editing on mobile devices with saved snippets.

What is the shortcut key for finding and replacing text?

The shortcut to find and replace text varies depending on the platform and application. Here are the most common shortcuts:

Windows (Microsoft Word, Notepad, etc.):

Ctrl + H

This opens the “Find and Replace” dialog in most programs.

Mac (Microsoft Word, TextEdit, etc.):

Command-Shift-H

This brings up the “Find and Replace” window on macOS apps.

Google Docs (Windows and Mac):

Ctrl + H (Windows) or Command-Shift-H (Mac)

These shortcuts open the Find and Replace menu.

Text Editors (VS Code, Sublime Text, Notepad++):

Ctrl + H (Windows) or Command-Shift-F (Mac)

These work for most code editors to search and replace in files.

Where is find and replace in Word on Mac?

To find and replace text in Microsoft Word on a Mac:

Open your document in Microsoft Word.

Click on the Edit menu at the top of the screen.

Select Find and then choose Replace from the dropdown (or simply press Command-Shift-H).

In the dialog box that appears, enter the text you want to find and the text you want to replace it with.

You can click Find Next to go through each instance or Replace All to replace every occurrence at once.

Additional options: Use the More button to access additional features like matching case, finding whole words only, or using wildcards for more complex searches.

How to do find and replace in Google Docs?

To find and replace text in Google Docs:

Open your Google Docs document.

In the top menu, click on Edit.

From the dropdown, select Find and Replace (or use the shortcut Ctrl + H on Windows or Command-Shift-H on Mac).

In the Find field, enter the text you want to search for.

In the Replace with field, enter the text you want to replace it with.

Click Replace to replace the current instance, or Replace All to replace all occurrences in the document.

Additional options:

Use the Match case checkbox if you want to match the exact capitalization.

Check Match using regular expressions for advanced pattern matching (useful for more complex searches).

Google Docs doesn’t allow for advanced options like replacing across different documents, but it’s still great for basic find and replace tasks.

When to go manual vs automated?

Use manual steps when precision is key. Use “Replace All” or scripts for large-scale changes—but only if you’ve previewed the results or backed up your files.

For even faster, smarter editing, TextExpander helps you go beyond search-and-replace with dynamic snippets, templates, and team-sharing features.