Stored Query to Remove CSS Comments
The comments in the CSS layouts that come with Dreamweaver CS3 are deliberately verbose—they’re there to help you understand what each rule is for. Although commenting style sheets is a good idea, you’ll probably want to get rid of the Dreamweaver comments once you’re familiar with the layouts. This stored query can be loaded into the Dreamweaver Find & Replace dialog box to remove all or some of the comments quickly and cleanly.
The query has been updated to remove the longer comments in the style sheets for the liquid, hybrid, and elastic layouts.
Note: Safari on Mac OS X automatically adds an
.xml filename extension to the stored query file when you download it. After downloading, select the file in Finder and press Cmd-I to open the Get Info panel. Remove the
.xml filename extension, and deselect the check box to hide the extension. The file must have a
.dwr filename extension for it to be recognized by Dreamweaver.
Instructions for use
- Open the style sheet in the Document window. If the styles are embedded in the
<head>of the document, switch to Code view.
- Launch Find & Replace from the Edit menu (or press Ctrl+F/Cmd+F).
- Click the Load Query icon at the top right of the Find and Replace dialog box. It looks like a folder with a document sticking out of it.
- In the Load Query dialog box, select
css_comment_remover_v3.dwr, and click Open. This loads the query into the Find and Replace dialog box and sets all the necessary options.
- To remove all the CSS comments in a single operation, click Replace All. This removes all comments, including any CSS hacks that look like comments. If you’re in any way uncertain, use the following more selective approach.
To remove comments selectively, click Find Next to highlight the first one. Click Replace to remove it or Find Next to move to the next one.
Dreamweaver always remembers your last find and replace operation, so these settings will be displayed the next time you open the Find & Replace panel. Delete the regular expression from the Find field and deselect the Use regular expression check box (unless you plan to use another regex). This final point is very important. When a find operation fails for no obvious reason, it’s usually because you have selected the Use regular expression check box by accident.