Editor with muti-line search and replace

I am looking for text editor for Windows which is capable of performing search and replace operation of multi-line text block.

It should be able to run this operation on a folder or currently opened files.

Ideally it supports regular expressions, but it's not essential.

Thanks!


Solution 1:

I used Notepad++ for a while when I still had to do stuff on a Windows computer; it's got decent support for regular expressions. It's got an intuitive interface, and you won't have to memorize key combinations and shortcuts.

Solution 2:

Vim

Blocks are selected with v, Ctrl-V, or Shift-V (among other ways). Once selected, substitute commands are run against the block by default.

Solution 3:

emacs

Use C-q C-j to specify a newline in the pattern to match or replace with. Plain text and regexp are supported, either all at once or in query mode (get confirmation for each match).

The functions you want are

replace-string
query-replace-string
replace-regexp
query-replace-regexp

and they can all be invoked with M-x <function name>. Some have default bindings.

Use C-h f <function-name> to learn what binding is currently assigned to any function.

To select a block from the text to use

  1. More the point to one end of the block. Hit C-<space>.
  2. Move the point to the other end. Hit C-w which will yank the whole block then C-y to return the yanked block or invoke copy-region-as-kill.
  3. M-x <function> then C-y to paste the block into the search space. Newlines are handled naturally.
  4. proceed as normal.

Solution 4:

EditPadPro for the win! It does everything you asked for:

  1. Multi-line search and replace
  2. Replace over all open files
  3. Regex support

Actually I think the free version does all of that too.

It is seriously the best text editor I have ever used. It has all the features you might need. I typically find it goes beyond the call of duty.

Solution 5:

Not an text editor, but you should give TextCrawler a shot. It is very lightweight and powerful tool to perform search and replace in files. A simple and good UI to put multiline text.

It allows Standard Search, Regular Expression, Fuzzy Search and Batch Commands.