With the help of HTML-Kit Tools‘ plugin managers, custom actions can be created and installed all without leaving the editor. These custom actions can add snippets, templates, right click items, keyboard shortcuts and other types of commands to speed up daily tasks.
Adding a snippet, the easy way
To create a new snippet, select the text that should be in the snippet and press Ctrl+Shift+T (or select "File > Insert > Add New Snippet" from the main menu). Type a name for the snippet in the "Title" field and click "OK."
To use the newly added snippet, press Ctrl+Shift+I ("File > Insert > Insert Snippet"). Optionally, the Snippet Window can be kept open to gain faster access to snippets ("File > Insert > Snippet Window").
Adding snippets with additional options
Although there are easier ways of adding snippets, some of the more advanced options are only available through the Plugin Manager. Once you get the hang of it, the few extra steps required to open the Plugin Manager should balance out by the other conveniences.
From the main menu, select "File > Insert > Edit and Manage Snippets." A Plugin Manager, or a Snippet Manager in this particular case, will open up. This dialog can be used to edit existing items and add new items.
Adding items in Plugin Manager
To add an item, click the "New" button. Fill in the required fields and click "OK." Once the item has been added, its content will be displayed on the right hand corner window. You can make changes and save them simply by editing the content.
Introducing text blocks
HTML-Kit Tools introduces "text blocks" to make it easier to manage plugin actions. These blocks are marked by "begin-text" and "end-text" lines, for example:
#@begin-text "default"
...
#@end-text "default"
This particular text block is labeled "default." Many plugin types use similar text blocks to contain information about various actions performed by plugins. Unless noted otherwise, the label "default" should be used because most plugins look for a default block.
What a plugin does with a text block depends on the plugin type. For example, in a snippet (a type of plugin), the default text block contains the text or the code that’s inserted by the snippet.
A simple text block
When the following text block appears in a snippet (or other type of plugin that insert text/code), the text "hello, world!" becomes the text that gets inserted:
#@begin-text "default"
hello, world!
#@end-text "default"
You can just as easily insert multiple lines of tags:
#@begin-text "default"
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
#@end-text "default"
Using the selected text
Often it’s useful to include the selected text as part of a snippet. You can do this by including the "{{SELTEXT}}" field and enabling the "useseltext" option as follows:
#@begin-text "default" [useseltext=1]
<li>{{SELTEXT}}</li>
#@end-text "default"
If you select some text before invoking this snippet, the final result becomes "<li>selected text</li>"
Moving the cursor
Need to place the cursor at a specific point in the text? Here’s how:
#@begin-text "default" [useseltext=1, movecursor=1]
<li>{{SELTEXT}}|</li>
#@end-text "default"
Enable the "movecursor" option and place the "|" (caret character without quotes) where the cursor should appear.
Prompting for user input
The new plugins interface in HTML-Kit Tools simplifies access to more advanced features. Let’s say you have a snippet that could benefit from having an input box. It’s as easy as adding a custom input field:
#@begin-text "default" [fields=1]
My name is: {{MyName}}
#@end-text "default"
In this example "{{MyName}}" is a custom field. When the snippet is invoked, HTML-Kit Tools prompts the user to fill in a field labeled "MyName." The entered value is then inserted in the snippet.
Here’s another example, this time with multiple custom fields:
#@begin-text "default" [fields=2]
My name is: {{FirstName}} {{LastName}}
#@end-text "default"
Want to use a custom field multiple times? Simply duplicate that field and HTML-Kit will only prompt for it once:
#@begin-text "default" [fields=2]
{{SomeNumber}} * 1 is {{SomeNumber}}.
#@end-text "default"
Conclusion
This article touches on the basics of creating custom actions in HTML-Kit Tools. You can use these custom actions to speed up adding and editing tags.
Don’t forget that these custom actions aren’t limited to snippets. You can add your own actions in other areas as well, including these commonly used features:
- Snippets
- "File > Insert > Edit"
- Templates
- "File > New > Edit"
- Right Click Menu / Editor Context Menu
- "Right click in editor > Extra > Edit"
- Shorthand
- "Tools > Shorthand > Edit" Enter custom text inside "begin-s" and "end-s"
- Keyboard Shortcuts
- "Tools > Keyboard Shortcuts > Edit" Enter custom text inside "begin-shortcut" and "end-shortcut"
- Context Keys
- "Tools > Context Keys > Edit"
- Project Items
- "Right click project item > Insert in Editor > Edit"
"default"