How to find and replace text within a text file
Finding and replacing text within a text file can be done using any text editor. Below is a listing of all the major text editors with information on how to replace text.
In Microsoft Windows, the Find and Replace option can be accessed by pressing the Ctrl+H or Ctrl+F keyboard shortcut in most programs. On Apple computers running macOS, this shortcut is either Command+H or Command+F.
Replacing text within Notepad
Microsoft Notepad is included with all versions of Windows and can replace text in plain text files. To replace text in Notepad, follow the steps below.
- Open the text file in Notepad.
- Click Edit on the menu bar, then select Replace in the Edit menu.
- Once in the Search and Replace window, enter the text you want to find and the text you want to use as a replacement. See our using search and replace and advanced options section for further information and help.
Press the keyboard shortcut Ctrl+H to open the Replace window.
The Replace feature in Notepad is limited. If you need to do more than only replace words, consider a different editor.
Replacing text with WordPad
Microsoft WordPad is included with all versions of Windows and can replace text in plain text files. To replace text in WordPad, follow the steps below.
- Open the text file in WordPad.
- In the Ribbon menu, on the Home tab (shown below), click the Replace option.
- In the Search and Replace window, enter the text you want to find and the text you want to use as a replacement. See our using search and replace and advanced options for further information and help.
Press the keyboard shortcut Ctrl+H to open the Replace window.
The Replace feature in WordPad is limited. If you need to do more than only replace words, consider a different editor.
Replacing text in Microsoft Word
To replace text in Microsoft Word, follow the steps below.
- Open the text file in Microsoft Word.
- In the Ribbon menu, on the Home tab, click the Replace option.
- In the Find and Replace window, enter the text you want to find and the text you want to use as a replacement. See our using search and replace and advanced options for further information and help.
Press the keyboard shortcut Ctrl+H to open the Replace window.
Clicking the More button in the Find and Replace window gives additional Search Options as shown in the above picture.
Replacing text with Notepad++
Notepad++ is a powerful free and open-source text editor that supports more options for finding and replacing text than any of the above suggestions. To replace text in Notepad++, follow the steps below.
- Open the text file in Notepad++.
- In the top menu bar, click Search and select Replace.
- In the Replace window, on the Replace tab, enter the text you want to find and the text you want to use as a replacement. See our using search and replace and advanced options for further information and help.
Press the keyboard shortcut Ctrl+H to open the Replace window.
Replacing text in TextPad
Although not free for the full program, TextPad is another fantastic text editor with powerful search and replace features. To replace text in TextPad, follow the steps below.
- Open the text file in TextPad.
- In the top menu, click Search and then Replace.
- In the Replace window, enter the text you want to find and the text you want to use as a replacement. See our using search and replace and advanced options for further information and help.
Press the F8 key to open the Replace window.
Find and replace text in Excel
The Ctrl+F and Command+F keyboard shortcuts also work in Microsoft Excel and other spreadsheet programs to open the Find and Replace text box.
In Microsoft Excel, older versions featured the Edit menu, and the Replace option is found in that menu. Newer versions of Excel feature a Ribbon menu, and the Find & Select option is found on the Home tab, at the far right side as shown in the picture.
Once the shortcut key opens or you click the Replace option under Find & Select, a Find and Replace window opens. On the Replace tab, enter the text you want to find and replace in the spreadsheet.
Using Search and Replace and advanced options
After understanding the above basics on how to open the search and replace features, understanding all the capabilities possible can make your searches even more efficient.
The basics
All the replace options have the two basic features shown below.
- Match case makes the search case-sensitive, which is useful for finding searches like Names.
- Match whole word matches the whole search instead of words containing the word. For example, a search for 'can' only matches 'can' and would not match 'cannot' or scan' in your file.
Wildcard and regular expressions
Programs like Microsoft Word that support wildcards and programs like Notepad++ and TextPad that support regular expressions help perform a search for almost anything imaginable. For example, using regular expressions you can replace text found at the beginning of a line, end of the line, works containing a certain amount of characters, and anything else you need.
Other advanced options
More advanced programs may have the features mentioned below. If your program does not include one of the features below, you need to consider switching programs with these features.
- Use wildcards is a feature found in Word that lets you use wildcards.
- Regular expression is the most powerful feature for finding and replacing text in a file.
- Sounds like (English) is a Word feature to match English sounding words. For example, searching for "color" would find "colour" in your document.
- Match prefix is a Word feature to match the prefix (beginning) of a word.
- Match suffix is a Word feature to match the suffix (end) of a word.
- Ignore punctuation characters is a Word feature to ignore punctuation marks like the single quote in "don't."
- Ignore white space characters is a Word feature to ignore spaces in words.