The Abbreviations function lets you quickly insert code snippets by entering their name in the editor buffer followed by Ctrl+T. Several useful default snippets are included in Komodo. Additional ones can be added easily.
Komodo looks for abbreviations in a special folder in projects and toolboxes called Abbreviations. Within the Abbreviations folder are language specific sub-folders, and a General sub-folder for global snippets.
To insert a snippet using Abbreviations, enter the name of the snippet in the
editor buffer, open Commando Ctrl+Shift+O (Meta+Shift+O on OS X), then search
for and select the command
cmd_expandAbbrev. Komodo searches for a
snippet matching the word to the left of the cursor in Abbreviations folders,
and replaces the word with the contents of the snippet if it finds one.
For example, to insert the
divblock snippet in an HTML file, type:
cmd_expandAbbrev in Commando ( Ctrl+Shift+O or Meta+Shift+O on OS X):
<div id="default"> </div>
Many of the default snippets in Komodo use Tab Stops (highlighted above) to make populating the snippet with your content even quicker. After inserting the snippet, the first tab stop is selected, just start typing to insert text in place of the marker. Use the Tab key to cycle through subsequent markers.
Note that if you use any snippets on a regular basis you should consider enabling their Auto-Abbreviation setting setting. See the next section for more information on Auto-Abbreviations.
You can also add a custom key binding to the
cmd_expandAbbrev command if you
prefer. Open the Key Bindings preferences and
search "Insert Abbreviation".
A snippet can be marked as an "auto-abbreviation" in its properties dialog. This means that when the snippet name is typed, followed by a trigger character, both the name and the trigger are replaced by the contents of the snippet. Trigger characters are specified in Preferences|Editor|Smart Editing|Auto-Abbreviations.
See Auto-Abbreviations for more information.
When Ctrl+T is entered, Komodo searches for relevant snippets in the toolbox. It first checks the language-specific subdirectory of the Abbreviations folder, then the General snippets. The first match gets inserted.
Exact case matches take precedence over mismatched case. For example, "Class" would trigger a snippet named "class" if there isn't one named "Class".
This allows you to have snippets with the same names for multiple languages. For example an abbreviation called 'class' abbreviation would insert a different snippet in a Perl file than in a PHP file.
To add a new abbreviation to the Toolbox, right-click on the appropriate sub-folder under Samples/Abbreviations and select Add|New Snippet....
To add a new abbreviation to a project, use the steps above after adding the necessary folders (i.e. at least Abbreviations/General) to the project.
As with all project and toolbox items, snippets can be copied, cut and pasted between toolboxes and projects.
© 2017 ActiveState Software Inc. All rights reserved. ActiveState®,
Komodo®, ActivePerl®, ActivePython®, and ActiveTcl® are registered
trademarks of ActiveState.
All other marks are property of their respective owners.