Saving Code Blocks as Snippets
With code snippets, you can easily store code blocks and content for reuse. Comment your snippets just as you would any code block.
To create a code snippet:
- Before adding a snippet, you must create a folder. To do so, click the Snippets tab in the Resources window, right-click in the Snippets panel, and select Create Folder from the menu.
You can create additional folders as needed. The default location for snippets is the \UserData\Snippets folder below your root directory.
- Enter a name for the folder.
- Right-click in the Snippets pane and select Add Snippet to open the Snippet dialog box.
- Enter a name for the snippet in the Description box. Note that snippet names cannot contain characters that are illegal in file names, such as slashes, special characters, or double quotes.
- In the Start Text window, type or paste an opening code block. You can set a default spacing between the blocks by pressing the Enter key at the end of the start text and at the beginning of the end text.
- In the End Text window, enter a closing code block.
- Click OK.
Because snippets can be created as start and end blocks, you can use them to surround other tags and content. This is handy for inserting special formatting, navigation elements, and script blocks. Simply highlight the content you want to surround, then insert the snippet.
To insert a code snippet, do one of the following:
- Double-click an entry in the Snippets panel.
- Right-click and select Insert into document from the popup menu.
To edit or delete a code snippet:
- Right-click the snippet and choose the appropriate command (Edit or Delete) from the snippets shortcut menus.
To manage code snippets and snippet folders:
- Use the snippets shortcut (right-click) menus.
You can share code snippets with other developers by giving them access to a shared folder on your machine or on another network machine.
To create a shared snippets folder:
- Open Options > Settings > Locations.
- In the Shared Snippets box, use the Browse button to navigate to the shared folder location and click OK.
- In the Snippets panel, right-click and select Create Shared Folder.
The folder button changes color to show that it is shared.
Anyone with access to the shared folder can now add, edit, and delete snippets.
Adding snippet shortcut keys
Open the Options > Customize dialog box and select the Snippet Shortcuts tab to enable a keyboard combination for a snippet. Select a snippet and press keys to enter the combination in the box at the bottom.
If a combination is in use, the current command appears below the shortcut box. To overwrite a combination, click Apply.