How to find and replace text within a text file

Updated: 04/01/2018 by Computer Hope

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.

Tip: In most programs, the Find and Replace option can be accessed by pressing the Ctrl+H or Ctrl+F keyboard shortcut on the PC. On Apple computers running macOS, the shortcut key may be either Cmd+H or Cmd+F.

Replacing text within Notepad

Microsoft Notepad is included with all versions of Windows and can be used to replace text in plain text files. To replace text in Notepad, follow the steps below.

  1. Open the text file in Notepad.
  2. Click Edit on the menu bar, then select Replace in the Edit menu.
  3. 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.

Tip: Press the keyboard shortcut key Ctrl+H to open the Replace window.

Note: The Replace feature in Notepad is limited. If you need more than just replacing words, consider a different editor.

Replacing text with WordPad

Microsoft WordPad is included with all versions of Windows and can be used to replace text in plain text files. To replace text in WordPad, follow the steps below.

  1. Open the text file in WordPad.
  2. In the Ribbon menu, on the Home tab (shown below), click the Replace option.
  3. 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.

Microsoft WordPad

Tip: Press the keyboard shortcut key Ctrl+H to open the Replace window.

Note: The Replace feature in WordPad is limited. If you need more than just replacing words, consider a different editor.

Replacing text in Microsoft Word

To replace text in Microsoft Word, follow the steps below.

  1. Open the text file in Microsoft Word.
  2. In the Ribbon menu, on the Home tab, click the Replace option.
  3. 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.

Find and Replace in Microsoft Word

Tip: Press the keyboard shortcut key Ctrl+H to open the Replace window.

Bonus Tip: Clicking the More button gives additional Search Options as shown in the above picture.

Replace 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.

  1. Open the text file in Notepad++.
  2. In the top menu bar, click Search and select Replace.
  3. 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.

Tip: Press the keyboard shortcut key Ctrl+H to open the Replace window.

Replace 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.

  1. Open the text file in TextPad.
  2. In the top menu, click Search and then Replace.
  3. 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.

Tip: Press the F8 key to open the Replace window.

Find and replace text in Excel

Tip: The Ctrl+F and Cmd+F keyboard shortcut keys also work in Microsoft Excel and other spreadsheet programs to open the Find and Replace text box.

Microsoft Excel Find and SelectIn 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 of the capabilities possible can make your searches even more efficient.

The basics

All of 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 can 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 feature one of the below features that you need consider switching programs so you have access to these features.

  • Use wildcards is a feature found in Word that allows you to 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.

Additional information