tenpastmidnight blog

Making hay while the sun shines

Editor that allows multi-line search and replace

I recently needed to take lumps of code out of a large number of pages for a client (EA Heliskiing.) They had lots of Javascript in-line in the page, and I was converting it to be a single external Javascript file. Having lumps of Javascript in the page is a bad idea - it means to change anything you have to update multiple pages rather than just one, and if it's in an external file the visitor's browser can cache it, meaning it won't need to download the same code every time a new page is loaded, which makes browsing quicker.

I needed to search and replace one multi-line section of code, with another, two-line section. My normal text editor (PFE) can handle mutli-line searching, but on a large amount of code it's tricky to set up because you can't see the several lines in the search box. I started looking for an editor that could take a large lump of text and search and replace that across multiple pages. Dreamweaver can do that very well, but I don't own it and I don't think it's worth buying just to use that one function.

After trying a few I've ended up with EditPlus, which has what I want in it's 'More' options in the search and replace facility. Unfortunately it's pay-for, although inexpensive, and I'm not interested in everything else it does as I'm happy enough with my PFE not to want to change.

So... if anyone knows a free editor or utility which will do what I want, please let me know. Otherwise I'm still looking for an editor which is as small, quick and easy to use as PFE, but has a little extra functionality in the search-and-replace stakes.
Comments:
I recently had this same issue Paul, after some searching around I went for this one:

http://www.divlocsoft.com/

Not free though - if you find anything better I'd like to hear about it.

- Nick W
 
I've had a similar problem on numerous occasions, and generally for the same reasons: a lot of inline code that needs stripping.

I've found that, though I use Notepad 2 http://www.flos-freeware.ch/notepad2.html as it's extremely lightweight (242Kb), it can't do that largescale search and replace. The free EditPad lite does the job, too, (
http://www.editpadpro.com/editpadlite.html
), but I don't personally like it as a general editor. It also allows regexp search and replace in the pay for version.

I've also given Aptana a shot, but it's quite bloaty and prone to bugginess. If you are looking to do a fairly powerful search and replace, a useful tool I've found is BTR Wizard, which would be part of the OS if Windows was Linux, but as it stands, BTR Wiz allows search and replace over multiple files in multiple folders.

I imagine there's a better way of doing this, but I've yet to find it!

Dan.
 
Post a Comment

Links to this post:

Create a Link



<< Home

This page is powered by Blogger. Isn't yours?