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).




mpp1031Asked:
Who is Participating?
 
Jason C. LevineNo oneCommented:
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

then

/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).

0
 
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.
0
 
Jason C. LevineNo oneCommented:
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:

http://www.macromedia.com/devnet/dreamweaver/articles/regular_expressions.html

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...
0
 
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.
0
 
Jason C. LevineNo oneCommented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.