If you've ever been frustrated at having to type the same piece of code over and over, you'll love snippets. A snippet is a piece of code stored in the HTML Editor that can be used and reused as many times as you need. You can save snippets of HTML, JavaScript, DHTML, Perl, or any other scripting language. The HTML Editor comes with several built-in snippets, and gives you the option to create your own.
Viewing Snippets
To see a list of available snippets, open the Snippets tab in the Resource browser on the left-hand side of the program. When you select a snippet name from the top pane, the code will appear in the bottom pane. All the built-in snippets come with a detailed HTML comment explaining what the code does.
Inserting Snippets
Use any one of the following options to insert a snippet into your page:
- Double-click its name.
- Select it and click the Insert Item Into Current Document icon in the Code Snippets toolbar.
- Right-click it and select Insert Item Into Current Document.
- Drag it onto your page.
Creating Snippets
To create a snippet, highlight the text you would like to save as a snippet and use one of the following options to open the Save Snippet window:
- Go to File > Save Selected Text as Snippet.
- Click the Save icon in the Toolbar and select Save Selected Text as Snippet.
Name the snippet and click OK. The new snippet will be added to the list in the Code Snippets tab.
You can also add a new snippet using the options in the Code Snippets tab:
- Click the New Snippet icon in the Code Snippets toolbar.
- Right-click a snippet and select New Snippet.
Both of these options open a new tab in the HTML Editor workspace. When you are done entering the snippet text, save the document normally. This opens the Save Snippet window.
Editing Snippets
To edit an existing snippet, select it and click the Edit Snippet icon in the Code Snippets toolbar. This opens the snippet code in a tab in the HTML Editor workspace. Edit it and then save it normally.
Deleting Snippets
To delete an existing snippet, right-click it and select Delete Snippet, or use the keyboard shortcut Del key. This opens a window asking if you are sure you want to delete the snippet. If you change your mind about deleting the snippet, click No.
Refreshing the Code Snippets Tab
If you have added, edited, or deleted a snippet but haven't seen the changes in the Code Snippets tab, click the Refresh icon in the Code Snippets toolbar. This refreshes the area so you can see the most up-to-date snippets.