Running the CodeSweeper to Format Code  
 
 

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

  • Visually editing page elements in Design mode can change code formatting. You can set CodeSweeper to apply its formatting rules when you leave Design mode.
  • You can painlessly enforce a code style guide for multiple developers by simply having them use the same settings.
  • You can easily clean up the code formatting of an existing project as you review the documents.


Click the CodeSweeper button on the Edit toolbar to run the selected CodeSweeper on the current document.
 
 
  Configuring CodeSweeper  
 
 

Select Options > CodeSweeper Settings to choose from the list of available CodeSweepers. ColdFusion Studio installs a CodeSweeper optimized for HTML, one that works on both HTML and ColdFusion Markup Language (CFML) tags, and one that you can use for testing. When you have selected a CodeSweeper, you can then specify the formatting rules you want to use.

 
 
  CodeSweeper settings  
 

You can set the following formatting rules for all tags:

  • Set case for tag and attribute names. You can choose all upper or lower case or preserve case, which leaves the case unchanged.
  • The Format event names setting contains an additional option -- Mixed Case -- which applies to case-sensitive JavaScript event handler names like OnMouseOver. If this code is correct in your document, select Preserve Case for this setting.
  • Set the use of quotes for values.
  • The Trim white space between tags setting cleans up spacing produced by some code generation tools. It is enabled by default. We recommend leaving it on and disabling it for individual tags as needed.

Click the Update button to save these settings.

 
 
  Tag-specific settings  
 

A wide range of options is available for the individual tags contained in each 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.

  • Insert a newline command for start and end tags.
  • Set indent by tabs or spaces -- a newline is inserted automatically for each indented line when this option is checked.
  • Enable indenting of nested sub-tags.
  • Override the general trim white space setting by preventing trimming of white space around the selected tag.
  • Leave the selected tag unchanged when invoking CodeSweeper.
  • Strip tag from document -- this is handy for getting rid of superfluous and unwanted tags inserted by code generation tools.
 
 
  To set rules for a tag:  
 
  1. Select a tag from the list.
  2. Change the specific settings.
  3. Click Update Tag to save the settings for that tag.
 
 
  To add a tag to a CodeSweeper:  
 
  1. Click Add Tag.
  2. Enter the tag name and click OK.
  3. Change tag settings.
  4. Click Update Tag to save the settings.

Check the "Apply Current CodeSweeper when switching from Design view" box to automatically run CodeSweeper on the active document when you leave Design view.

 
 
  Adding a new CodeSweeper  
 

You can easily create custom CodeSweepers to fit specific document types or coding styles.

 
 
  To add a new CodeSweeper:  
 
  1. Click the Add button.
  2. Enter a name for the new CodeSweeper.
  3. Change global and tag settings.
  4. Click Update to save the settings.


 
 
BackUp LevelNext
 
 

allaire     AllaireDoc@allaire.com
    Copyright © 1998, Allaire Corporation. All rights reserved.