Find and Replace several several different values all at once

Take a look at Sed. You can easily achieve your goal by only one command line

sed -e "s/Text_1/TextA/" -e "s/Text1/TextB/" <your_file.txt>your_file_new.txt


Since Notepad++ 6.0 it is actually possible without scripts using the following technique:

Find: Text_1 and Replace with: Text_A

Find: Text2 and Replace with: TextB

Find: (Text_1)|(Text2)

Replace: (?1Text_A)(?2TextB)

The general syntax is:

Find: (FindA)|(FindB)|(FindC)...

Replace: (?1ReplaceA)(?2ReplaceB)(?3ReplaceC)...

?1 refers to the first captured phrase and so on.

I got this from the following answer: https://stackoverflow.com/a/16104946/287101


Using Notepad++, You can either

  • Open all files containing the words you want to replace and make use of Find / Replace in all open files

    enter image description here

  • Use Find / Replace in files

    enter image description here

  • Record a macro performing the find and replace options and play it back


You're better off running Find & Replace twice, because you have two different replacements happening. However, there should be very little tradeoff in processing time. Consider the following:

Running Find & Replace once, searching term by term:

Get Term
  Does term match?  If so, replace term
Get Next Term
...

For running purposes, we'll assume it's linear and say that this runs in O(n) time.

You want to find two different terms. Running Find & Replace twice looks like:

Get Term
  Does term match?  If so, replace term
Get Next Term
...

Get Term
  Does term match?  If so, replace term
Get Next Term
...

which would take O(2x1n) time, or twice as long as searching for one term.

Searching for two terms with two replacements would theoretically look like:

Get Term
  Does first term match?  If so, replace first term
  Does second term match?  If so, replace second term
Get Next Term
...

Getting the terms does not take that much processing power, so essentially you are looking up two sets of searches for each term, giving a time of O(1x2n), running once but searching two terms.

While you would save some time not loading each term twice, you would spend more time searching each term twice, so there's little tradeoff, and since this feature would be used less often than searching one term with one replacement, application developers just assume not write that functionality.

DISCLAIMER TO PROGRAMMERS: This is a generalized example. I know it is better but I'm trying to show why that feature isn't found.