July 8, 2005

Dreamweaver MX 2004 Source Code Formatting

I finally found the secret of changing Dreamweaver MX 2004 source code formatting. I happen to be one of those people who likes HTML code just so. No endlessly nested indents; beyond a certain point, all that indenting causes more confusion than it apparently exists to solve. DWMX2004 now stacks tags line by line:

<p>stuff</p>
<p>stuff</p>

Well ::ahem:: I find line upon line of such code difficult; a blank line now and then would be welcome. Searching DW's Help section and the DW forums, I found:

  1. Set Preferences in the Tag Libraries
    Edit>Preferences>Code Format>Tag Libraries (the last is a tiny link)
    But this does not give you the double-line space
  2. Edit the .vtm configuration files in
    C:>Program Files>Macromedia>Dreamweaver MX 2004>Configuration>TagLibraries>HTML
    (on a Windows machine, of course — but this doesn't do it, either)

So, #1 doesn't do it, and … #2 doesn't do it.

Solution, Part A: if you're having this problem, the answer is expressed more than once in the DW forums, but not in a particularly decipherable manner — one that illuminates what the problem is and how and where to solve it. That is, if yours is a Win2K machine or other OS that allows multiple user logins, there are (or will be — keep reading) a duplicate set of configuration files in your user area. And that user area is not in C:>Program Files>etc. — it's here:

C:>Documents and Settings>username>Application Data>Macromedia>Dreamweaver MX 2004>Configuration

You can get to these files via Windows Explorer. Edit the particular .vtm file for which you wish to change code formatting (example: p.vtm, blockquote.vtm) and save. But wait! There's more! If those files are not in your user area:

Solution, Part B: Surprise! The .vtm files do not appear in your user Application Data folders until created via DW's internal Preferences/Tag Libraries link (see #1 above). Do that first, then edit the .vtm file (the tags are fairly straightforward), and -presto!- your new Dreamweaver MX 2004 source code formatting takes precedence.

See, wasn't that easy? And fabulously intuitive? <Geez>

Just pulling your leg a bit, Macromedia; I do love your products, but a little clarification would have made it easier. And the fact that some of us are using a WYSIWYG does not mean we're not code-fussy. <grin>

17 Comments to "Dreamweaver MX 2004 Source Code Formatting"

  1. Darren Fujiyama says:

    This is weird…i'm using DW8 and even though i specify in tag libraries to line break BEFORE, INSIDE, and AFTER, I still have td tags which dont break correctly. What i want to happen is avoid having a long td tag, AND ALL OF ITS CONTENTS on the same line. I'd like to break it up a bit, especially when the tag contains a ton of code inside of it.

    I've done a manual "Apply source formatting" after i edited the tag library and still nothing. I've checked the VTM files in Documents and Settings and they look fine to me. What gives?

  2. DianeV says:

    Okay. The issue is *which* .vtm files to check.

    Assuming that you're using Windows, the generic settings in c:program files aren't the ones — you need to check the ones that apply to you as a
    *user* of the machine. That is, when you log in as a "user" of that machine. Those settings (after you do the Tag Libraries thing) are stored elsewhere in *your* user settings:

    C:>Documents and Settings>username>Application Data>Macromedia>Dreamweaver MX 2004>Configuration

    Is that what you did?

  3. DianeV says:

    Actually, I see that you've done that. I'm not quite sure why that wouldn't be making the changes you wanted (although I've had a bit of the same problem myself, but only on occasion). Am assuming you closed and restarted DW, and perhaps rebooted (though I think this shouldn't be necessary).

    One other thing: have you played around with View>Code View Options>Word Wrap?

    Selecting Word Wrap will make the code wrap around *visually* within DW without its being wrapped around in the code itself.

    Otherwise, I'm a bit running out of suggestions here. :(

  4. James Kafka says:

    I'm having a problem with

    tags not formatting according to my tag library setting. I want them to break before, inside and after. I followed your advice to check and update the .vtm files for the tag. Every td.vtm file on my system is in sync. However, DW8 won't follow the settings. I have stopped-started DW8, no change. Nothing seems to work.

    All other tags format properly. It's just the tag that I'm having problems with.

    Any other advice …?

  5. Diane Vigil says:

    I took a look at the Adobe Dreamweaver forums.

    This one seems to have had the same problem, but doesn't verify that editing the Tag Libraries worked for TDs.

    Does your td.vtm file have something like this?

    <tag name="td" endtag="yes" casesensitive="yes">
    <tagformat nlbeforetag="1" nlaftertag="1"/>

  6. Diane Vigil says:

    Ah, perhaps this will help:

    Check your prefs, code format–>Tag libraries–>Line Breaks

  7. James Kafka says:

    DianeV,

    Yes, here are the first two lines from my td.vtm file in DW8:

    <tag name="TD" endtag="yes">
    <tagformat nlbeforetag="1" nlbeforecontents="1" nlaftercontents="1" nlaftertag="1" indentcontents="yes"/>

    My Code Format Prefs are:

    Line breaks: Before, Inside, After
    Contents: Formatted and Indented
    Case: default

    DW8 even shows an example of how the code should be formatted:

    text
    <td>
    tag contents
    </td>
    text

    When I Apply Source Formmatting my tables still look like:

    <table>
    <tr>
    <td>Contents ….
    …</td>
    </tr>
    </table>

    Best regards,
    JEK</tagformat></tag>

  8. DianeV says:

    Okay. (I had to edit your comment to use characters instead of the <> brackets, as WordPress tries to read them apparently as code.)

    I really don't know the answer for this (I'd check the link I gave above) but I'll note that DW has a Code View option that can make the code look different within DW than it does in the browser. It's pretty cool because you can have your code *not* wrap around on the Web, but look wrapped around within DW … making it easier to read and deal with within DW.

    I'm not hopeful that this will solve the problem, but might it have something to do with this (View>Codeview)?

  9. KoRnDragon says:

    I was having some of the same problems as above and found that messing with the TR and TABLE line break options fixed the TD settings the way I wanted them.

  10. James Kafka says:

    Diane,

    I just found the solution to my TD formatting issue. There is a setting in Preferences | Code Format labeled "No break after TD" and I had it checked. The label seems obvious, but somehow I always overlooked this setting. I must have reviewed the Preferences 20 times !!

    Anyway, after un-checking this option, my tables now format beautifully.

    Best regards,
    JEK

  11. DianeV says:

    That's terrific, James. I'm glad that you found it. I'd seen that setting too, but forgotten to mention it here, so thanks.

  12. Darren Fujiyama says:

    Wow over a year later and I still haven't found the fix until now. James' preferences checkbox fixed the problem. Thanks!

  13. Diane Vigil says:

    Excellent, Darren. Yes, we all like our code the way we like it. :)

  14. Iulian says:

    Hey there. That's very cool stuff. I had the same problem for very long already. I want to notice that this setting in Adobe Dreamweaver CS4 you can find it at Preferences->Code Format->TD tag and you can uncheck it also.

    I found also why this setting does not conform with the tag library specification. As Adobe ex Macromedia says and they're right:

    "TD Tag: Do Not Include A Break Inside The TD Tag
    Addresses a rendering problem that occurs in some older browsers when white space or line breaks exist immediately after a tag, or immediately before a tag. When you select this option, Dreamweaver does not write line breaks after a or before a tag, even if the formatting in the Tag Library indicates that the line break should be there."

    You can find the article right here.

  15. Diane Vigil says:

    Ah, good information, Julian. Although I suspect they may be talking about *very* old browsers. I do remember having TD coding issues years ago.

  16. Jacob Dybala says:

    You may want to take a look at this solution: http://www.jacobdybala.com/apply-source-formatting-in-dreamweaver-for-entire-site

    This is the plugin you are looking for.

  17. Diane Vigil says:

    Hi Jacob. Although I haven't tried your plugin, I've approved your comment.

Have your say ...

First-time comments will be held for moderation (but comments are appreciated). Otherwise, just be courteous. If your name is a bunch of keywords, your comment will be deleted. Don't post links unless highly pertinent. Posters must be 16 or older.

Manage your subscriptions

Archives
© 2004-2017 DianeV Web Design Studio. All Rights Reserved.
34 queries. 0.254 seconds.