Komodo Snippet for Comment Banners

I like to keep my code organized and easy to read, but since I am almost always working on a tight deadline, I do not always have time to organize and comment my code as well as I would like to. Shortcuts that aid in keeping my code organized are more likely to get used than their longer counterparts. Comment banners are one way to keep code organized, especially in large files.

In Komodo, the following snippets will turn highlighted text into a comment banner, or if no text is selected, pop up a dialog box asking for the Banner Title. After inserting the banner, the cursor will be be positioned below it. These snippets will work for any code editor, IDE, etc. if you leave out the [[%(s:orask:Banner Title)]] or replace it with whatever works for your software.

You can set a key binding for this shortcut in the ‘Key Binding’ tab of the snippet properties dialog window.

To create a new snippet in Komodo Edit or IDE, open up the Toolbox pane (View > Tabs & Sidebars > Toolbox), and either click on the gear icon and choose ‘New Snippet’, or right-click on a folder where you want to store the snippet and choose ‘New Snippet’.

The snippet dialog box will appear. Give the snippet a title, and place the following text into the larger text box:

PHP, C, C++, C#, Java, JavaScript, ActionScript, etc.:

////////////////////////////////////////////////////////////////////
// [[%(s:orask:Banner Title)]]
////////////////////////////////////////////////////////////////////

PHP, JavaScript, CSS, ActionScript, C, C++, C#, Java, etc.:

/*//////////////////////////////////////////////////////////////////
// [[%(s:orask:Banner Title)]]
//////////////////////////////////////////////////////////////////*/

Small Banner:

/* ---------------- [[%(s:orask:Banner Title)]] ---------------- */

HTML, HTML5, XHTML:

<!---------------- [[%(s:orask:Banner Title)]] ------------------->

The important part is the interpolation shortcut ([[%(s:orask:Banner Title)]]). You can make the banner look however you like as long as the text is wrapped in code that denotes a comment. Make sure to position the cursor a line or two below the banner.

Check the box for ‘Maintain selected text or cursor position after insertion’. The second check box is optional, but recommended. When you are finished, the box should look something like this:

Komodo PHP Comment Banner Snippet
Komodo PHP Comment Banner Snippet

Click ‘OK’ to save the snippet.

To use the snippet, highlight or enter the banner text and double-click on the snippet in your Tools pane or type your keyboard shortcut. Your banner will be inserted and the cursor will be positioned and ready for the next line of code.

Leave a Comment