Komodo Edit, an code editor based on Mozilla, has a nice features called "Macro", allows programming of UI. This applies to version 8.5 in MacOSX.
First, open Toolbox sidebar, right click / click on Setting button in top-right corner, we will have a list of customisation available (command, macro, snippet).
My favourite list:
1. View current file in Shift JIS
Japanese legacy code are largely written in Shift JIS encoding.
Adding this Javascript macro let you quickly switch:
komodo.assertMacroVersion(3);
var koDoc = ko.views.manager.currentView.koDoc;
if (koDoc.encoding.short_encoding_name != "Shift JIS") {
koDoc.setEncodingFromEncodingName("Shift JIS");
}
I often assign Cmd + Shift + J shortcut to this.
2. Open GitX for this file
Git should be init beforehand (or you can add a command for init : )
The "%D" represents current folder of current file.
Add a command look like below, and set your own shortcut key:
Based on this, you can easily create a shortcut for executing PHP, Python script:
3. Move the current line up / down
The days before I works with Notepad++, above useful shortcuts are missing in Komodo.
However, we can "emulate" it using 2 macros.
Script below are taken from Komodo forums:
http://community.activestate.com/forum/move-line-move-line-down-macros
For move selection / current line down
// Move Line or Move Selection Down
komodo.assertMacroVersion(3);
if (komodo.view) { komodo.view.setFocus() };
var ke = komodo.editor;
if( ke.lineFromPosition( ke.currentPos ) == ( ke.lineCount - 1 ) )
return;
// Prevent Undo remember macro steps
ke.beginUndoAction();
var sel_start_a = ke.selectionStart;
var sel_end_a = ke.selectionEnd;
// Extend selection to beg of line at front and end of line at back
var selStartLine = ke.lineFromPosition(ke.selectionStart);
var selEndLine = ke.lineFromPosition(ke.selectionEnd);
var numLinesSelected = selEndLine - selStartLine;
var selStart = ke.positionFromLine( selStartLine );
var selEnd = ke.getLineEndPosition( selEndLine );
ke.setSel( selStart, selEnd );
// Determine original selection position offset related to extended
var sel_start_b = ke.selectionStart;
var sel_end_b = ke.selectionEnd;
var offset_start = sel_start_a - sel_start_b;
var offset_end = sel_end_b - sel_end_a;
// Copy the selected text and remove it
var text = komodo.interpolate('%s');
komodo.doCommand('cmd_delete'); // This leaves a blank line in place of selection
// Move our selection to a new place
// First move our blank line up
komodo.doCommand('cmd_lineNext')
ke.lineTranspose();
// Insert our text
ke.insertText(ke.currentPos, text);
// Restore selection
var newSelStartLine = ke.lineFromPosition( ke.currentPos );
var newSelEndLine = newSelStartLine + numLinesSelected;
var newSelStart = ke.currentPos + offset_start;
var newSelEnd = ke.getLineEndPosition(newSelEndLine) - offset_end;
ke.setSel(newSelStart, newSelEnd);
// End of prevent Undo
ke.endUndoAction();
For moving up:
// Move Line or Move Selection Up
komodo.assertMacroVersion(3);
if (komodo.view) { komodo.view.setFocus() };
var ke = komodo.editor;
if( ke.lineFromPosition( ke.currentPos ) == 0 )
return;
// Prevent Undo remember macro steps
ke.beginUndoAction();
var sel_start_a = ke.selectionStart;
var sel_end_a = ke.selectionEnd;
// Extend selection to beg of line at front and end of line at back
var selStartLine = ke.lineFromPosition(ke.selectionStart);
var selEndLine = ke.lineFromPosition(ke.selectionEnd);
var numLinesSelected = selEndLine - selStartLine;
var selStart = ke.positionFromLine(selStartLine);
var selEnd = ke.getLineEndPosition(selEndLine);
ke.setSel(selStart, selEnd);
// Determine original selection position offset related to extended
var sel_start_b = ke.selectionStart;
var sel_end_b = ke.selectionEnd;
var offset_start = sel_start_a - sel_start_b;
var offset_end = sel_end_b - sel_end_a;
// Copy the selected text and remove it
var text = komodo.interpolate('%s');
komodo.doCommand('cmd_delete'); // This leaves a blank line in place of selection
// Move our selection to a new place
// First move our blank line up
ke.lineTranspose();
komodo.doCommand('cmd_linePrevious')
// Insert our text
ke.insertText(ke.currentPos, text);
// Restore selection
var newSelStartLine = ke.lineFromPosition( ke.currentPos );
var newSelEndLine = newSelStartLine + numLinesSelected;
var newSelStart = ke.currentPos + offset_start;
var newSelEnd = ke.getLineEndPosition(newSelEndLine) - offset_end;
ke.setSel(newSelStart, newSelEnd);
// End of prevent Undo
ke.endUndoAction();
4. Find and replace
The find window is often get lost because of Windows overlap.
A solution is clicking pin icon on the right down corner.
Also, set proper include and exclude pattern may help while searching on a directory.
My exclude pattern is:
vendor:.svn:.git:template_c:*~
The regex in replace box using notation \1, .. \n for matched groups.
5. Emmet
Emmet is an add-on for typing HTML faster.
Watch how amazing it is at
http://docs.emmet.io/
I often set key Shift - Enter for expanding emmet abbr.
6. Keybindings
Key with * are not set by default.
Cmd + Shift + K = Invoke tool
*Cmd + P = Quick open (like Sublime does, but we need to create a "project" beforehand)
*Cmd + | = Browser preview split view: the page reload on save
*Cmd + M = Duplicate line or selection
*Cmd + G = Go to line
*F4 and Esc = Complete word
*Cmd + K = Set mark
*F10 = Show current file in places