|
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, then enter Ctrl+T
(Meta+T on OS X). 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.
If multiple snippets with the same name are found in the same scope (see Language-Specific Search Order below), an
autocomplete drop box is shown, allowing you to select the snippet you
want.
For example, to insert the divblock snippet in an HTML
file, type:
divblock|
Enter Ctrl+T to insert the snippet:
<div id="«id»>
«»
</div>
Many of the default snippets in Komodo use Tab
Stops (represented by the «» symbols) to make populating the
snippet with your content even quicker. After inserting the snippet, the first
tab stop marker is selected, just start typing to insert text in place of the
marker. Use the Tab key to cycle through subsequent
markers.
When Ctrl+T is entered, Komodo searches for relevant snippets in
the current project, the toolbox, and the shared toolbox (in that order).
Komodo checks the language-specific sub-directory and the General
sub-directory in each of these places. For example, if you are editing
a Python module, these snippet directories will be checked in this
order:
- Abbreviations/Python folders in:
- Current Project
- Toolbox
- Shared Toolbox
- Abbreviations/General folders in:
- Current Project
- Toolbox
- Shared Toolbox
In a multi-language buffer, both the language type of the file and
the language type at the current cursor position are included. For
example, in a JavaScript block inside a PHP file, the following search
order would be used:
- Abbreviations/JavaScript folders in:
- Current Project
- Toolbox
- Shared Toolbox
- Abbreviations/PHP folders in:
- Current Project
- Toolbox
- Shared Toolbox
- Abbreviations/General folders in:
- Current Project
- Toolbox
- Shared Toolbox
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.
|