Find and Replace using Dreamweaver

After seeing Dreamweaver pulled through the mud by people who deem it a poor tool for development, I’ve decided to shed some light on features that I feel have saved me countless time and may help you in your quest to produce better web sites faster. One specific feature that stands out for me is the Find and Replace tool.

For all you PC users, a CTRL-F will bring the Find dialog right up.

Basic Find and Replace

Find and Replace Dialog in Dreamweaver

The basic dialog that comes up looks like a normal find and replace dialog box; although somewhat larger than you might be used to in other programs. You can enter in multiple lines of text and replace it with multiple lines of text. This is quite handy if you’re just replacing large blocks of HTML. The ignore whitespace feature is helpful in that it ignores things like extra lines, spaces and tabs in between tags and attributes. Code has a habit of becoming inconsistent in its formatting from page to page.

You can also do regular expressions which is also helpful. I find that the regular expression support in Dreamweaver is decent but I prefer using other programs like UltraEdit if it’s strictly just a regular expression. Dreamweaver is certainly slower than UltraEdit and I imagine other programs for this kind of thing.

But hit the drop down beside Search and you’ll see some other options:

Drop down in Find and Replace Dialog

The difference between Source Code and Text is much like it describes: a find and replace in Source Code view will match HTML elements and attributes whereas a find and replace in Text mode will only find matches in anything you see in Design view.

Slightly more advanced Find and Replace

Advanced Text Find and Replace Dialog

The Text (Advanced) option is where you truly begin to experience some of the power of Dreamweaver’s Find capabilities. You’ll be able to search for text inside or not inside specific tags. Hitting the plus sign will allow you more options to narrow down your search. You can continue hitting the plus sign to add more options to the search. On the second-plus options you can additional options such as specifying that elements have to have certain attributes to be matched.

For example, let’s say you want to replace a word in the sidebar but never in the content area. For those of us who’ve wrapped the sidebar in a div with a class or id attached to it, you could specify to look for your word Inside Tag div, With Attribute id = sidebar. No other occurrences of the word would be replaced.

The whole enchilada: Specific Tag searches

Specific Tag Find and Replace Dialog

I’m sure accessibility gurus will balk at my example screen shot of attaching a target to all my links. In any case, this is the feature that seems so hidden that most who’ve used Dreamweaver never seem to know it is there and always seemed amazed when I show them. What a Specific Tag search can do is match specific elements.

You can strip out elements, set attributes, remove attributes. Let’s say you’ve just moved your rollover scripts to use some fancy unobtrusive JavaScript and now you need to remove all onmouseover and onmouseout events that you have. Simply look for all a tags With Attribute onmouseover and Remove Attribute and then do the same for the onmouseout. If you wanted to be more selective, you could use a regular expression to ensure that the attributes contained specific code such as your rollover function.

Backup, Backup, Backup

Okay, before you go hog wild I must warn you that no matter what program you use, I highly recommend you make a backup before doing any site-wide find and replace. Oft times you replace things you really didn’t want replaced and when there’s no undo, you may find yourself spending hours redoing it. Not that I’ve done that or anything *cough*.

Published September 21, 2005 · Updated September 21, 2005
Categorized as Dreamweaver
Short URL: https://snook.ca/s/415

Conversation

20 Comments · RSS feed
Jeff J. Snider said on September 21, 2005

Hey Jonathan, good post. I also have found many of the tools in Dreamweaver to be indispensible, including this Find & Replace. I look forward to your future posts if this is a series you are starting, and I may be feeling the urge right now to do the same thing over on my blog, if you don't mind. (I have been wanting to start posting more web stuff and not just baseball stuff.)

I personally didn't think Dreamweaver was "pulled through the mud" as much as you did, based on your comments at Roger's site. But I do agree that Dreamweaver has a bit of a bad rep as "just another WYSIWYG tool," when really, it has many, many useful tools even for someone who doesn't ever use the WYSIWYG part. FTP is my favorite, as I mentioned over there and on my site, but there are many others. Thanks for getting the ball rolling on this.

John Nunemaker said on September 22, 2005

I just got Studio 8. Dreamweaver 8 has some amazing new features. One of the sweetest is the ability to expand and collapse sections of code. Simply highlight and collapse. You can then double click the collapsed area to expand the region once again.

8 also improves auto completion. I always hated auto completion but 8 hadles it well. If you type a start tag such as <li> in front of some text and then move your cursor to the end of the line and begin to type your end tag it finishes it for you. Very nice. There is nothing bad with dreamweaver as long as you avoid the WYSIWIG. I just stay in code view and it keeps me happy.

Wesley Walser said on September 22, 2005

I have't looked at design view in the last 3 years, but there are definetly tools within Dreamweaver that make it worth the purchase price for me.

Perhaps now that you have talked about it people won't feel the need the down it so much. I feel like a lot of the time we decide that because everyone is saying bad things we have to, flash would be the example that comes to mind.

In any case, good times, good post. I would add that finding PHP variables in a large client site tends to be made a lot easier with find/replace, and the tools that come along with it in Dreamweaver.

fabien. said on September 22, 2005

John : I hated the previous auto-completion too, now it is really clever the way it works.
One of the very good thing in DW8 is the FTP manager too, you can transfert files in the background, when before you was stuck while it was transfering. Really great improvement.

Jeff J. Snider said on September 22, 2005

In case anyone is interested, I posted a little thing like this over on my blog, focusing on the integrated FTP. Thanks for the idea, Jonathan!

fabien. said on September 22, 2005

Nice Jeff. I wrote some things last week too.

Chris Mewhort said on September 22, 2005

Hi Jonathan. Long time reader -- but I don't know if I've ever commented. I agree with the "dragged through the mud" statement. Dreamweaver has such a bad reputation (as I guess all WYSIWIG's do) becuase so many people don't know how to use it.

One thing you didn't mention was the Find and Replace "Find in: Open Documents" which of course searches all open documents. This option has saved me HOURS of work on multiple occassions.

Glad to know there are other Dreamweaver fanatics out there.

Here's to Dreamweaver.

Ben Snape said on September 22, 2005

Yep, I couldn't live without the site wide find and replace in DW. Ok, other html authoring programs probably have this feature too, but it is very useful indeed.

Graham said on September 22, 2005

We use Studio 8 where I work, and I love working with Dreamweaver. I used to use MS Notepad to code sites, but I got turned onto Dreamweaver's great code-editing features and have not looked back. Like everyone else here, I NEVER use "design view" to actually create layouts, but I do occationally use it if I'm just editing content.

Another great DW feature besides Search and Replace is its ability to convert MS Word content into basic HTML. Admittedly, it works best with just simple p, ul, ol, li, and hn tags, and DW8 is still a little buggy when compares to MX, but this feature lets me grab conent from Word, and slap it into DW with p/li/ol/ul tags preserved. It does this at XHTML compliance levels to boot. This has saved me countless hours of wrapping blocks of text in p tags.

Scott said on September 22, 2005

At one of my part time jobs I spend a lot of time marking up content to go into an admin system for various clients. Sometimes, we're doing a redesign and I have to pull the content off of sites that were built years ago. Dreamweaver has been a godsend for me, because I can strip font tags automatically without affecting the content. Also, the keyboard shortcuts (ctrl+1-6 for headings) are handy when copying content for new sites out of client worksheets.

With a myriad of other useful features, dreamweaver works as a supercharged text editor for me. It's a shame that I don't get to flex more of it's muscle (because for basic text editing, it costs an awful lot) but it is essential to my productivity as an entry level (read bored and unhappy) web professional.

iflynn said on September 22, 2005

I couldn't keep reading the comments on Rogers page - I just got angrier and angrier at the foolish elistism running rampant there. I started out hand coding in notepad in '95, but was given Dreamweaver 2 at the uni when I quit freelancing. By now we're using DW MX 2004, creating pages using css+xhtml, templating everything and setting our content managers up with Contribute (we have over 150 content managers here with a range of no-html knowledge to the semi-pro). DW is a godsend. I'd like to see a hand-coder change say a navigation element on a 500 pg site that filters through all the pages in less than 5min. Thank you for being the voice of reason.

cody lindley said on September 22, 2005

A positive perspective coupled with factual proof. Clever! And well, people who are stilling using a text editor to write complex applications/website to establish some sort of elite attitude are simply allow their own pride to segregate their skill set from archiving the next level of proficiency, regardless the choice of IDE.

Jeff J. Snider said on September 22, 2005

I really think the big issue here is that way too many people on both sides of the issue are seeing a strict dichotomy, a black and white issue, when really there is a whole lot of gray area.

Some of the hand-coders are lumping all users of Dreamweaver in together, even though there are vastly different levels of Dreamweaver usage. Yes, it is possible to use Dreamweaver to create crappy sites with absolutely no knowledge of what you are doing; it is also possible to use Dreamweaver very wisely and efficiently to maximize your coding power.

On the other hand, some of the DW-users are lumping all hand-coders into the "they write out complex tables of billions of cells by hand, the dummies!" group. Yes, there probably are some people like that. But there are certainly some hand-coders who use PHP or other server-side languages to generate those complex tables from databases, or who have found some efficient way other than WYSIWYG to create complex tables.

As with almost everything that is reduced to "this or that," the answer is usually somewhere between "this" and "that," which means that the majority of people weighing in on the issue are at least partly wrong.

Graham said on September 22, 2005

I know that DW isn't exactly free, but when you look at evrything you get when you buy the Studio Suite, its not all THAT bad either.

We (have to) use Flash from time to time, so we'd be buying it seperately anyway, and I've really gotten to love Fireworks for doing site comps, so I'd buy that one a la carte as well. I've got one firm right now on Contribute, so when you look at all those factors, DW is pretty cheap when you're buying all the Studio programs anyway.

Joe Maddalone said on September 22, 2005

It's no TextPad ( http://www.textpad.com ) but it is light years ahead of any real competition when it comes to handcoding.

Jakester said on September 22, 2005

Cool, I'll have to try it, I have DW but never use it cause I like making lean html files with Edit Plus. Thanx!

Jeremy Flint said on September 24, 2005

I have never really been a big DW user. My main code-editing app is HomeSite, which is essentially what is now used as DW's code editor.

HomeSite has always had the Find/Replace and the Code Collapse, which everyone seems to be making a big deal about now for some reason.

Greg Rewis of Macromedia is supposed to be here in town in October to give an overview of Studio 8's new features, so that should be interesting.

Jesse said on June 01, 2006

yeah dreamweaver is great. Though PSPAD (http://www.pspad.com/) Freeware also allows Search and Replace, not only that -- it has a Search and Replace in Files. Its lightweight and fast with a lot of the features dreamweaver has, a great tool if you need an alternative.

Charlie said on October 12, 2006

I wrote this article on improving dw's find and replace function using perl and Unix command lines tricks. Hope you like it.

Charlie said on October 12, 2006

sorry - link here http://www.neptuneweb.com/downloads/better_find_and_replace_on_html_content.html

Sorry, comments are closed for this post. If you have any further questions or comments, feel free to send them to me directly.