Working with code snippets

Working with code snippets

Code snippets let you store content for quick reuse. You can create and insert snippets of HTML, JavaScript, CFML, ASP, JSP, and more. Dreamweaver also contains some predefined snippets that you can use as a starting point.

This section describes how to insert, create, edit or delete code snippets. It also describes how to manage your code snippets and share them with other members of your team.

To insert a code snippet:

  1. Place the insertion point where you want to insert the code snippet, or select code to wrap a snippet around.
  2. In the Snippets panel (Window > Snippets), double-click the snippet.

    You can also right-click (Windows) or Control-click (Macintosh) the snippet, then select Insert from the pop-up menu.

To create a code snippet:

  1. In the Snippets panel, click the New Snippet icon at the bottom of the panel.

    The Snippet dialog box appears.

  2. Complete the dialog box and click OK.

    For more information, see Setting the Snippets dialog box options.

To edit a code snippet:

  • In the Snippets panel, select a snippet and click the Edit Snippet button at the bottom of the panel. This is a picture of the feature being described.

To delete a code snippet:

  • In the Snippets panel, select a snippet and click the Remove button at the bottom of the panel. This is a picture of the feature being described.

To create code snippet folders and manage code snippets:

  1. In the Snippets panel, click the New Snippet Folder button at the bottom of the panel.
  2. Drag snippets to the new folder or other folders, as desired.

To add or edit a keyboard shortcut for a snippet:

  1. In the Snippets panel, right-click (Windows) or Control-click (Macintosh) and select Edit Keyboard Shortcuts.

    The Keyboard Shortcuts Editor appears.

  2. In the Commands pop-up menu, select Snippets.

    A list of snippets appears.

  3. Select a snippet and assign a keyboard shortcut to it.

    For more information, see Customizing keyboard shortcuts.

To share a snippet with other members of your team:

  1. Find the file corresponding to the snippet that you want to share in the Configuration/Snippets folder in the Dreamweaver application folder.
  2. Copy the snippet file to a shared folder on your computer or a network computer.
  3. Have the other members of the team copy the snippet file to their Configuration/Snippets folder.


Getting Started with Dreamweaver
Dreamweaver Basics
Working with Dreamweaver Sites
Laying Out Pages
Adding Content to Pages
Working with Page Code
Setting Up Your Coding Environment
Preparing to Build Dynamic Sites
Making Pages Dynamic
Developing Applications Rapidly