Creating a Snippet
In a Snippet Set Window
Click the “+ Snippet” button at the bottom of the snippet set window.
TypeMetal creates a new, initially empty and untitled snippet, in the snippet group where the current selection resides. (If your snippet set doesn’t have any groups, TypeMetal creates a group to put the snippet in.)
TypeMetal then highlights the snippet’s title (initially, “New Snippet”) for editing, so you can easily name the snippet. Give the snippet a title that conveys its purpose or intended usage. This will help you (or another author using your snippet set) choose appropriate snippets when applying snippets in a document.
Once you’ve named your new, initially empty snippet, you’ll want to proceed to giving it some content.
In an HTML Window
When editing an HTML file that has an associated snippet set, you can easily define a new snippet from any selection in the HTML document. Create new snippets on the fly, as you notice things you’re building repeatedly. Then find and apply them with the ease of a few keystrokes as you continue writing.
There are two snippet creation commands, for the two kinds of snippets you’ll want to create:
- Most often, you’ll want to create a “simple” snippet, which consists of a single element with attributes, wrapped around a
{content}
placeholder token. When you create a simple snippet from a selected HTML element, TypeMetal omits the example element’s content from the snippet, yielding a snippet that can be wrapped around other content when you invoke it. The command for creating a simple snippet is “New Simple Snippet…”, and its keyboard shortcut is Command+Control+/ - Sometimes, you’ll want to create a snippet that includes arbitrary text content, or more than one element. The more general snippet creation command, “New Snippet from Entire Selection” enables you to do this. You’re likely to want to edit the snippet’s content after you invoke this command, to get it just the way you want it.
These snippet creation commands are available in three places:
- the Structure menu
- the content editing area’s context menu
- a path bar segment’s context menu
If these commands are disabled in the menus, make sure your document has an associated snippet set, and make sure you are operating on an appropriate selection. A “simple” snippet can only be created from an exactly selected HTML element (or a right-clicked element segment in the path bar), not from an arbitrary selection.
When you create a new snippet using one of these commands, TypeMetal adds it to the HTML file’s associated snippet set, and opens the snippet set’s editor window with the new snippet selected. You may then want to give the snippet a meaningful title, edit the snippet’s content, or move the snippet elsewhere within the snippet set.