Preserving Code Formats with CodeSweepers

The CodeSweeper feature automates the task of getting your code properly formatted. It can be very useful in a number of situations:

Studio includes a number of CodeSweepers for you to use. You can also create your own CodeSweepers or edit the existing ones. Studio CodeSweepers include:

See the Allaire Developer site for an interesting article on CodeSweeper features.

Setting and using the default CodeSweeper

Click the CodeSweeper button from either Edit or Design modes to run the default CodeSweeper on the current document. You can also set the default CodeSweeper to run automatically when you leave Design mode.

Note To set the default CodeSweeper:
  1. From the Options menu, choose Settings (F8) to see the Settings dialog box.
  2. Click CodeSweeper to see the CodeSweepers pane.

  3. Select the CodeSweeper that you want to use as the default from the list and click Set as Default.
  4. Click OK.
Note To run a CodeSweeper automatically after leaving Design mode:
  1. In the Settings dialog box (F8), click Design.
  2. Click Apply CodeSweeper when return from design view.
  3. Click OK.

Using a CodeSweeper other than the default

You can use a CodeSweeper other than the default at any time. Changes are made to the current document only.

Note To use a CodeSweeper other than the default:
  1. Click the down arrow on the CodeSweeper button, or choose Tools > CodeSweeper and choose from the list of available CodeSweepers.

    You are notified that the CodeSweeper will format the entire document and cannot be undone.

  2. Click Run CodeSweeper.

    The document is formatted.

Creating, editing, and removing CodeSweepers

You can create new CodeSweepers, edit existing CodeSweepers, and remove outdated CodeSweepers using the Settings dialog box (F8).

Note To create a new CodeSweeper:
  1. Open the Settings dialog box (F8).
  2. Click CodeSweeper to see the CodeSweepers pane.
  3. Click New Profile to see the New CodeSweeper Profile dialog box.

  4. Enter a name for the CodeSweeper and choose its type: Allaire CodeSweeper or HTML Tidy CodeSweeper.
  5. Click OK.

    The CodeSweeper is added to the list.

  6. Follow the directions below to edit the CodeSweeper to fulfill your needs.
Note To edit a CodeSweeper:
  1. In the Settings dialog box (F8), expand CodeSweeper.
  2. Expand the node for the type of CodeSweeper you want to edit: Allaire CodeSweepers or HTML Tidy CodeSweepers.
  3. Select the CodeSweeper you want to edit to see the CodeSweeper settings.
  4. Make any changes to the settings and click OK.
Note To remove a CodeSweeper:
  1. In the Settings dialog box (F8), click CodeSweeper.
  2. Select the CodeSweeper you want to remove from the list on the right and click Remove Profile.

    The CodeSweeper is removed without warning.

CodeSweeper settings

There are three types of CodeSweeper settings:

General settings

You can set the following formatting rules for each Allaire CodeSweeper.

Click the OK button to save these settings.

Tag-specific settings

A wide range of options is available for the individual tags contained in each Allaire CodeSweeper. Note that if you set formatting for the "All Other Tags" entry in the tag list, those rules apply to every tag that appears in a document that is not in the list.

Note To set rules for a tag:
  1. Select a tag from the Tag Specific Settings list in the CodeSweeper Settings dialog box.
  2. Change the specific settings.
  3. Click Update Tag to save the settings for that tag.
Note To add a tag:
  1. Click the Add Tag button in the CodeSweeper Settings dialog box.
  2. Enter the tag name and click OK.
  3. Change tag settings and click Update Tag to save the settings.
Note To remove a tag:
  1. Select a tag from the Tag Specific Settings list in the CodeSweeper Settings dialog box.
  2. Click Remove Tag.
  3. Click OK to close the Settings dialog box.

HTML Tidy settings

The HTML Tidy author's Web site is http://www.w3.org/People/Raggett/tidy/. You can access this web site from the HTML Tidy Settings pane. Refer to this web site for detailed descriptions of all the HTML Tidy settings in the Settings dialog box.

Creating a custom profile

You can create your own custom configuration text file and save it with a .tdy extension to the your \extensions\Codesweepers folder.