How to prevent auto-tag-completion on "search and replace" in Dreamweaver MX 2004

I'm using Dreamweaver MX 2004 to update some badly-marked-up HTML documents.  My process is to use the Find/Replace feature to blow through whole directory trees of HTML and fix a few tags and issues at a time.  It works quite well.

There is a particular problem that keeps coming up.  I don't know if it's me, or if it's Dreamweaver.  It would seem that when I attempt to "surround" a particular tag sequence with another tag, I don't get my desired results.  Let me 'splain with an example:

Existing HTML looks like this:

<a name="target">Blah De Blah</a>

What I want the Replace feature to do is this:

<h2><a name="target">Blah De Blah</a></h2>

(I assumed that I would have to do that in TWO steps; using 'Add Before Start Tag', and then 'Add After End Tag' in my search/replace activity).

However, what I get when I search for '<a>' tags with a 'name' attribute of '[any_value]' and tell DW to 'Add a <h2> Before Start Tag' is this:

<h2></h2><a name="target">Blah De Blah</a>

Likewise, if I try 'Add After End Tag', I get:

<a name="target">Blah De Blah</a><h2></h2>

I've tried turning OFF the 'Auto Tag Completion' feature in Edit > Preferences > Code Hints, but that doesn't seem to have an effect on Search/Replace.

Any ideas on how I can fix this?  I can't use a different version of Dreamweaver, and I really can't use another product (corporate bureaucracy at work here).

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jason C. LevineDon't talk to me.Commented:
Hi mpp1031,

Two things to try:

1) Go to Edit | Preferences | Code Rewriting and turn off "Fix invalidly nested and unclosed tags"

That may or may not work.  I can't fully replicate what you are seeing in DW 8.  When I tried it, DW closed the h2 tag if it was not in a paragraph tag.  In other words, if the <a> occurred within a <p>, then the <h2> did not close.  When the <a> was not in a <p>, the tag auto-closed when using F/R for specific tags.

Now that I think about it, also check under General for "Switch to plain paragraph after heading" to see if it is enabled or not.  If enabled, try disabling.

2) Don't use tag search to do something that is this simple.

Just search in Source Code for <a and replace it with <h2><a


/a> replaced with  /a></h2>

This worked no matter where the <a> was located, unless <a and /a> appear in your content as text (not links).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mpp1031Author Commented:
I'm not at work right now, but on Monday I'll try #1.

Problem with your #2 suggestion is that I have *other* <a> tags that *are* links (i.e. with href attributes) that I would not want to enclose in <h2></h2> tags.  I suppose I could try doing a more complex Regular Expression search, but I suck at Regexes, so that's a last resort.
Jason C. LevineDon't talk to me.Commented:
Meh.  Obviously you can start the h2 by searching for <a name= but closing them would be tough.

The better question to be asking here is if MM is going to let you put a new tag in front of or behind a tag, why the heck couldn't they have added a wrap tag option to the F/R function?

I did a little more digging and #1 should work for you.  What appears to be happening is that by using tag F/R, DW is re-validating the code as it goes along.  So by turning off the validation it should be okay.  I'm not at my normal location this week, so I can't test it first :(

The DW regular expressions are not like "normal" regular expressions.  They are a little simpler to define and use and MM devnet has a good tutorial:

I can't normally write a regex to save my life, but I have been able to write them in DW with only a minimum of pain.  Bonus:  you can save the F/R definitions once you get one that works...
mpp1031Author Commented:
I think I've found a compromise *solution* (however "bootleg" it might be):

I do my F/R, but instead of telling DW to replace with <h2>, I specify \h2\ (since backslashes aren't typically used very much in these pages, if at all... I hope), and \/h2\ for the end tag, of course.  It takes me FOUR steps instead of 1 or 2, but it does get my desired result.  I suppose I could use some other character (or cominbation of characters) instead of the backslash.

I'll leave this open, briefly, if anyone else has any comments or a better/different solution...

jason1178, I checked this morning when I got in, and I already had the "Fix nested tags" feature disabled, as well as ALL the code-rewriting options, and it still doesn't work as it *should*.  I even tried turning them back on in various combinations, even specifying that HTM and HTML documents never be rewritten.  DW didn't care.  It insists on throwing the whole tag combination in there, even if I only want the opening tag.  Weird.
Jason C. LevineDon't talk to me.Commented:
I can confirm that it is odd.  I tested it over the weekend and played around with all the various toggles and got the same results.  Again, the only thing I can think of is that when F/R on tags, DW goes into validation mode and closes the tag no matter what you specify.

Oh well.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Dreamweaver

From novice to tech pro — start learning today.