Notepad++ Tutorial How to find and replace in files using Notepad++

Published: February 8, 2019 (Updated: Feb 8, 2019)

Enjoying this content? Subscribe to the Channel!

The Essential Notepad++ Trick: Find and Replace Text Across Multiple Files Instantly

Hey there, tech enthusiasts! Darren here from Darren’s Tech Tutorials.

If you’ve ever had to update a common string—like a server name, a variable, or a deprecated function—across dozens, or even hundreds, of files, you know the pain. Manually opening, searching, editing, and saving each file is a soul-crushing time sink.

Luckily, if you use the fantastic, free text editor Notepad++, there is a powerful solution built right in! This feature allows you to execute a “Find and Replace” operation across an entire folder directory in seconds.

This tutorial is run on Windows 10, but the process is virtually identical regardless of your operating system, as long as you have Notepad++ installed. Let’s dive in and save you a ton of time!


Why Use Find and Replace in Files?

This powerful feature is a lifesaver for developers, system administrators, and anyone dealing with large website directories or code bases. Imagine you’ve moved your server from localhost to myserver.com. Instead of editing 30 configuration files individually, Notepad++ handles the mass update instantly.

Setting Up the Search Directory

Before we open Notepad++, the first step is to identify the folder containing all the files you need to modify.

  1. Navigate to the Directory: Using Windows Explorer (or your preferred file manager), open the folder that holds the target files (e.g., your collection of scripts or configuration files).
  2. Copy the Path: Click into the address bar at the top of the file manager window and copy the full directory path. This is crucial for telling Notepad++ exactly where to perform the search.

While you can jump straight to replacing, it’s always smart practice to run a search first to confirm you are targeting the right text and the right files.

  1. Open the Search Window: In Notepad++, press Ctrl + F to open the Find dialogue box.
  2. Switch Tabs: Click on the Find in Files tab.
  3. Configure Your Search:
    • Find What: Enter the string you want to search for (e.g., localhost).
    • Directory: Paste the path you copied earlier into the “Directory” field.
    • File Filters (Optional): If you only want to search, say, PHP files, you can enter *.php in the “Filters” field. Leaving this blank searches all files.
  4. Execute Search: Click Find All.

Notepad++ will display all occurrences of the string, broken down by file, in a results pane at the bottom of the window. This confirms that your directory and search term are correct.

Step 2: Executing the Multi-File Replacement

Now that we know the string exists, we can safely replace it.

  1. Return to Find in Files: Press Ctrl + F again and ensure you are on the Find in Files tab.
  2. Define Replacement:
    • Find What: Re-enter the string you want to change (e.g., localhost).
    • Replace With: Enter the new string you want to use (e.g., my_new_server).
    • Directory: Ensure your target directory path is still correct.
  3. Run the Replacement: Click the Replace in Files button.

⚠️ A Crucial Warning!

Notepad++ is going to give you a warning: “It will replace all occurrences in all files in the current folder.”

This is a destructive action! Always double-check your Find What and Replace With strings. If you are confident, click OK.

  1. Confirmation: Notepad++ will run through the entire directory and list how many total occurrences were replaced.

Verifying the Change

To confirm the replacement worked flawlessly, simply perform a final search:

  1. Go back to the Find in Files tab.
  2. Search for your original string (e.g., localhost). The results should show zero findings.
  3. Now, search for your new string (e.g., my_new_server). You should see results confirming that all your old strings have been successfully updated across all files!

Wrapping Up

This Notepad++ feature is a real game-changer for workflow efficiency. Once you incorporate this technique, you’ll never waste time manually editing files again.

I hope you found this quick guide useful! If you enjoyed this tutorial and learned a new trick, please be sure to like this post and subscribe to Darren’s Tech Tutorials for more clear and accessible technology guides.

Happy coding!