PSPad: Multiline Search & Replace

Have you ever wanted to search and replace more than a single line of text?

All the text editors I’ve used will only search and replace one line at a time. And this is not always workable. There may be ways around that I haven’t discovered yet. If I only need to search and replace a few times I’ll use the usual copy and paste. But last night I had a job to do that would have required doing it manually over 300 times.

What I found is a text editor called PSPad. It’s a great little (free) text editor, available in several languages and much better than Window’s Notepad (if you’re still using only that).

Search & Replace, PSPad

There’s an add-on script available for it called phReplace. After you have PSPad installed, unzip the phReplace files into the PSPad directory. In Windows, that’s C:\Program Files\PSPad editor\

The files should go to the right place automatically but he gives you a check-list just in case. There are only 4 files so it’s not difficult to double-check.

Now, when you open PSPad, there will be an option under ‘Scripts’ called Multiline Search/Replace. Click on that and here’s the box.

Multiline Search/Replace, PSPad

Put your original text in the top, and your replacement text below, pick your options on the right and Replace. Hours of search and replace work condensed into minutes.

There’s somewhat of a caveat to this. I noticed that:

aaaaa bbbbb ccccc

is not recognized as being the same thing as:

aaaaa bbbbb
ccccc ddddd eeeee

What I did at the end of the process was take a phrase from my original text, (that does not exist in the replacement text) and run it through a simple Search to make sure it wasn’t there anymore. I did find some files where the text had not been replaced (for the above reason I’m assuming) so I went through those manually.

If you don’t yet have a good quality text editor be sure to install one. It can be a real boon to your work depending on your needs. They have the ability to open and manipulate hundreds of files at once in a matter of seconds.

Another one that I use everyday is Notepad++.

Leave a Reply

Your email address will not be published. Required fields are marked *