Multi line search and replace tool

search

I am looking for a tool to replace multiple lines through out a project. For example:

#include "../DiscreteIO/Discrete.h"
#include "../PCI/pci.h"
#include "../Arinc429/ARINC429.h"

with

#include "../PCI/pci.h"
#include "../DiscreteIO/DiscreteHW.h"
#include "../DiscreteIO/Discrete.h"

I have tried two tools that work for this type of search and replace. Wildedit and Actual search and replace Both seem to be excellent tools but are shareware. Do anybody know of similar tools? Anything free or is it time to part with some money?

Clarification:

through out a project in this case means a thousand plus c files. The text editors can do this only one file at a time (Textpad, Programmers notepad) or in all open files(nodepad++). I haven't tried any of the other editors but I assume they will have similar problems. Please correct me if I am wrong.

Tools like sed & awk is a solution but present problems since I do not use them regularly and need to spend some time getting something to work since I am not a expert on the tools.

The answer is: All of it…

Ultra edit can work but I already have an editor and the price is steep if I am just going to use it as a search and replace tool.

Sed, AWK and regular expression based tools can work but can be a pain in some cases.

Wild Edit can work and is not that expensive.

My decision in the end is to work my Regular expression skills.

Best Solution

The JetBrains family of IDEs: IntelliJ, RubyMine, PHPStorm etc. will do a multi-line search and replace.

Select the text in question and press ctrl-shift-F -- this will open the replace dialog with the selected text as the find expression (using a regex with newlines escaped as \n)

Related Question