View comments | RSS feed

Dreamweaver CS3  |  Go to CS4 Help

Change the code format

You can change the look of your code by specifying formatting preferences such as indentation, line length, and the case of tag and attribute names.

All the Code Format options, except the Override Case of option, are automatically applied only to new documents or additions to documents that you subsequently create.

To reformat existing HTML documents, open the document, and select Commands > Apply Source Formatting.

  1. Select Edit > Preferences.
  2. Select Code Format from the Category list on the left.
  3. Set any of the following options:
    Indent
    Indicates whether code generated by Dreamweaver should be indented (according to the indentation rules specified in these preferences) or not.
    Note: Most of the indentation options in this dialog box apply only to code generated by Dreamweaver, not to code that you type. To make each new line of code that you type indent to the same level as the previous line, select View > Code View Options Auto-Indent option. For more information, see Set the code appearance.

    With
    (Text box and pop‑up menu) Specifies how many spaces or tabs Dreamweaver should use to indent code that it generates. For example, if you type 3 in the box and select Tabs in the pop‑up menu, then code generated by Dreamweaver is indented using three tab characters for every level of indentation.

    Tab Size
    Determines how many characters wide each tab character appears in Code view. For example, if Tab Size is set to 4, then each tab is displayed in Code view as a four-character-wide blank space. If, additionally, Indent With is set to 3 Tabs, then code generated by Dreamweaver is indented using three tab characters for every level of indentation, which appears in Code view as a twelve-character-wide blank space.
    Note: Dreamweaver indents using either spaces or tabs; it doesn’t convert a run of spaces to a tab when inserting code.

    Automatic Wrapping
    Inserts a line-break character (also known as a “hard” return) when a line reaches the specified column width. (Dreamweaver inserts line-break characters only in places where they don’t change the appearance of the document in browsers, so some lines may remain longer than the Automatic Wrapping option specifies.) By contrast, the Wrap option in Code view displays long lines (that extend beyond the width of the window) as if they contained line-break characters, but doesn’t actually insert line-break characters.

    Line Break Type
    Specifies the type of remote server (Windows, Macintosh, or UNIX) that hosts your remote site. Choosing the correct type of line break characters ensures that your HTML source code appears correctly when viewed on the remote server. This setting is also useful when you are working with an external text editor that recognizes only certain kinds of line breaks. For example, use CR LF (Windows) if Notepad is your external editor, and use CR (Macintosh) if SimpleText is your external editor.
    Note: For servers that you connect to using FTP, this option applies only to binary transfer mode; the ASCII transfer mode in Dreamweaver ignores this option. If you download files using ASCII mode, Dreamweaver sets line breaks based on the operating system of your computer; if you upload files using ASCII mode, the line breaks are all set to CR LF.

    Default Tag Case and Default Attribute Case
    Control the capitalization of tag and attribute names. These options are applied to tags and attributes that you insert or edit in Design view, but they are not applied to the tags and attributes that you enter directly in Code view, or to the tags and attributes already in a document when you open it (unless you also select one or both of the Override Case Of options).
    Note: These preferences apply only to HTML pages. Dreamweaver ignores them for XHTML pages because uppercase tags and attributes are invalid XHTML.

    Override Case Of: Tags and Attributes
    Specify whether to enforce your specified case options at all times, including when you open an existing HTML document. When you select one of these options and click OK to dismiss the dialog box, all tags or attributes in the current document are immediately converted to the specified case, as are all tags or attributes in each document you open from then on (until you deselect this option again). Tags or attributes you type in Code view and in the Quick Tag Editor are also converted to the specified case, as are tags or attributes you insert using the Insert bar. For example, if you want tag names always to be converted to lowercase, specify lowercase in the Default Tag Case option, and then select the Override Case Of: Tags option. Then when you open a document that contains uppercase tag names, Dreamweaver converts them all to lowercase.
    Note: Older versions of HTML allowed either uppercase or lowercase tag and attribute names, but XHTML requires lowercase for tag and attribute names. The web is moving toward XHTML, so it’s generally best to use lowercase tag and attribute names.

    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 <td> tag, or immediately before a </td> tag. When you select this option, Dreamweaver does not write line breaks after a <td> or before a </td> tag, even if the formatting in the Tag Library indicates that the line break should be there.

    Advanced Formatting
    Lets you set formatting options for Cascading Style Sheets (CSS) code and for individual tags and attributes in the Tag Library Editor.

    White Space Character
    (Japanese version only) Lets you select either &nbsp; or Zenkaku space for HTML code. The white space selected in this option will be used for empty tags when creating a table and when the “Allow Multiple Consecutive Spaces” option is enabled in Japanese Encoding pages.




Comments

Comments are no longer accepted for Dreamweaver CS3. Dreamweaver CS4 is the current version. To discuss Dreamweaver CS3, please use the Adobe forum.

Comments


No screen name said on Oct 23, 2007 at 9:36 AM :
Is it possible to auto-format the code so that there is a blank line between tags (or just certain tags)?
LoriHC (Dreamweaver Team) said on Oct 23, 2007 at 10:57 AM :
Yes. Generally line breaks and indenting of individual tags are handled by the Tag Libraries. To edit these, go to Edit > Tag Libraries...

If you want an extra line after a tag (as I do for P tags, for example), change the Line Breaks to either Before and After Tag or Before, Inside, After, and click OK. Then navigate to your user Configuration folder (it'll be inside Documents and Settings/yourname/Application Data/Adobe/Dreamweaver 9/ if you're on Windows; on Mac, I believe it's in your Library/Application Support/Adobe/Dreamweaver 9/ folder) and look inside the TagLibraries folder. Since I edited the settings for P, I see an html folder with a p.vtm file inside. Open the .vtm file in a text editor and change

nlaftertag="1"

to nlaftertag="2". This will give you a blank line after the closing tag. I think the changes will take effect right after you save the .vtm file, but if they don't, you may need to restart.
No screen name said on Oct 25, 2007 at 5:22 PM :
I'm trying to set my code format preferences so that code is only ever indented with 4 spaces. However, my tab size is set to 4, so every time it indents code, it uses a tab instead of spaces! How can I fix this? I'm using Dreamweaver CS3.
JasonRB said on Nov 21, 2007 at 9:22 AM :
I would like to know how to do the "space when I press tab" also.
LoriHC (Dreamweaver Team) said on Nov 21, 2007 at 9:52 AM :
If you're looking for an "insert tabs as spaces" option, sadly Dreamweaver doesn't have one. To request such an option, please use the Feature Request/Bug Report Form at http://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
kprobbins said on Jan 30, 2008 at 1:41 PM :
Weird. I have the exact opposite problem. When coding, if I hit the next line, it converts the tabs to spaces, rather than leaving them as tabs, which is what I would prefer.

Can I stop the automatic 4 spaces and just have it create one tab?
Tom Corder said on Mar 28, 2008 at 3:23 AM :
Ditto to the above. After a tabbed indent then pressing newline (Enter) now results in spaces being used to pad to the same depth. All very well and it seems more "standards" compliant but why am I forced to have to delete 4 separate spaces instead of one tab to drop back an indent level? I'd like to be able to choose to be non-compliant but work quicker!
oringe said on Sep 30, 2008 at 6:34 PM :
kprobbins and Tom - I had the same issue as you but I think there's a way to fix that. Go to Edit -> Preferences and then select Code Format.

Make sure the first checkbox is seleted, and input "1" and then select "Tabs" from the drop down menu.

Then on the next option, Tab size, input "4" (or whatever you like).

That worked for me!

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/en_US/Dreamweaver/9.0/WSc78c5058ca073340dcda9110b1f693f21-7bdd.html