Komodo User Guide

Code Snippets

Code snippets are selections of frequently-used code. They can be stored in the Toolbox or the Project Manager, and quickly inserted into the current document.

Creating Snippets

To create a code snippet, select the desired block of text in the editor pane. Then drag and drop the selected section to the Toolbox or the Project Manager.

Alternatively, select the desired text, then right-click and select Add as Snippet in the Toolbox.

Alternatively, right click in the Toolbox or on a project or folder name in the Project Manager and select Add Snippet. If you use this method, you must manually enter the contents of the snippet; text selected in the editor pane will not be automatically added to the snippet dialog.

Configuring Snippets

To configure snippet properties, right-click the snippet in either the Toolbox or the Project Manager, and select Properties. The following configuration properties are available:

  • Snippet Name: enter the text that should display in the Project Manager or Toolbox for this code snippet. If the snippet was created by dragging a text selection from the editor pane, the snippet will be named after the text in the snippet.
  • Snippet Contents: if the snippet was created by dragging a text selection from the editor pane, the contents of the selected text will be displayed in the Snippet Contents field. Otherwise, you must enter the contents of the snippet manually. Add or edit snippet content as desired.
  • Maintain selected text or cursor position after insertion: within the snippet contents field, you can select a portion of the snippet (by dragging the mouse pointer over the desired selection). Also, you can set the position of the editing cursor within the snippet. If this box is checked, when the snippet is inserted into the editor pane the selected text or the cursor position will be displayed in the same manner in the editor pane.
  • Maintain indentation context after insertion: if you insert the snippet into the editor pane when the editing cursor is in an indented position, check this box to use the indentation point as an indentation "prefix". The indentation structure of the snippet will be preserved at the position of insertion.

Using Snippets

To insert the contents of a snippet at the current cursor position in the editor pane, double click a snippet in either the Toolbox or the Project Manager. Alternatively, right-click the snippet and select Insert Snippet.

Snippet Key Bindings

Top