Vi emulation mimics the modal behavior of the Vi editor. The Vi scheme (and custom schemes created with Vi emulation) require this emulation in order to assign keystrokes to appropriate actions in the various modes.
Keybinding schemes and Vi emulation are configured in Edit|Preferences|Editor|Keybindings.
Komodo emulates the following Vi modes:
When you open a file in Komodo with the Vi scheme enabled, you start off in command mode. Keystrokes in this mode control movement, deletion, cutting, pasting and other standard editing commands that are generally mapped to Ctrl and Alt key combinations in other schemes.
Hitting an "input" command key in Normal mode (i.e. 'i' to insert, 'a' to append, or 'o' to open a new line and insert) puts the editor into Input mode. Keystrokes in this mode enter text. Use the 'Esc' key to exit into Normal mode.
Similar to Vim's visual modes. Entering 'v' enables selection by character, 'V' enables linewise selection, and 'Ctrl'+'v' enables blockwise selection. Navigation keystrokes within these modes expand and contract the selection area. Use the 'Esc' key to exit into Normal mode.
In Normal mode, entering ':' opens a text box in the status bar at the bottom of the Komodo window for entering Vi commands. The following Vi and Vim commands have been implemented in the default Vi scheme:
To add your own Vi commands, create a Toolbox folder named Vi Commands, then add Macros or Run Commands to the folder. The macro or command is executed when you type its name in the Vi command-line text box.
Command-line arguments can be passed to Macros using the
koIViCommandDetail
XPCOM service. The IDL for this
service is:
attribute long startLine; // Start line (current line when unset) attribute long endLine; // End line (current line when unset) attribute boolean forced; // Command name ended with a "!" attribute wstring commandName; // Command name being run attribute wstring leftover; // Everything after the command attribute wstring rawCommandString; // Raw command string as typed in void getArguments(out unsigned long count, [array, size_is(count), retval] out wstring args); void setArguments(in unsigned long count, [array, size_is(count)] in wstring args); void clear();
JavaScript sample macro:
var viCommandDetails = Components.classes['@activestate.com/koViCommandDetail;1']. getService(Components.interfaces.koIViCommandDetail); var count = new Object(); var args = viCommandDetails.getArguments(count); var msg = "startLine:" + viCommandDetails.startLine + "\n" + "endLine:" + viCommandDetails.endLine + "\n" + "commandName:" + viCommandDetails.commandName + "\n" + "arguments:" + args + "\n" + "rawCommandString:" + viCommandDetails.rawCommandString; alert(msg);
Python sample macro:
from xpcom import components viCommandDetails = components.classes['@activestate.com/koViCommandDetail;1'].getService(components.interfaces.koIViCommandDetail) msg = [ "startLine: %d" % viCommandDetails.startLine ] msg.append("endLine: %d" % viCommandDetails.endLine) msg.append("commandName: %s" % viCommandDetails.commandName) msg.append("arguments: %r" % viCommandDetails.getArguments()) msg.append("rawCommandString: %s" % viCommandDetails.rawCommandString) print "\n".join(msg)
The default Vi scheme is based on the Default scheme (which varies slightly between platforms) and includes all Default keybindings which do not conflict with those used in Vi emulation. To view the list of key bindings for your current scheme, select Help|List Key Bindings. The following are key bindings which are unique to the Vi scheme.
Cancel |
|
||
Cut One Character |
|
||
Cut One Character to Left |
|
||
Cut to End of Line and Enter Insert Mode |
|
||
Delete the Current Character and Enter Insert Mode |
|
||
Deletes from cursor to end of line. |
|
||
Enter Insert Mode |
|
||
Enter Insert Mode after the Cursor Position |
|
||
Enter Insert Mode at Start of the Line |
|
||
Enter Insert mode at the End of the Current Line |
|
||
Enter command mode |
|
||
Enter visual block mode |
|
||
Enter visual character mode |
|
||
Enter visual line mode |
|
||
Go to Next Line |
|
||
Go to Previous Line |
|
||
Goto Line |
|
||
Join current and next lines |
|
||
Move Left One Character |
|
||
Move One Word Left |
|
||
Move Right One Character |
|
||
Move To End of Word To Right |
|
||
Move To Start of Word To Right |
|
||
Move one page down |
|
||
Move one page up |
|
||
Move one word left, past any punctuation |
|
||
Move one word right, past any punctuation |
|
||
Move to Beginning of Line (first visible char/first column) |
|
||
Move to Beginning of the Current Line |
|
||
Move to Beginning of the Previous Line |
|
||
Move to End of Current Line |
|
||
Move to end of word to the right, past any punctuation |
|
||
Move to the Beginning of the Paragraph |
|
||
Move to the Beginning of the Section |
|
||
Move to the Beginning of the Sentence |
|
||
Move to the Bottom of the Screen |
|
||
Move to the Center of the Screen |
|
||
Move to the End of the Paragraph |
|
||
Move to the End of the Section |
|
||
Move to the End of the Sentence |
|
||
Move to the Top of the Screen |
|
||
New Line Starting After the Current Line |
|
||
New Line Starting Before the Current Line |
|
||
Paste |
|
||
Paste After |
|
||
Redo |
|
||
Repeat the last command again |
|
||
Replace characters with the ones that are typed |
|
||
Replace the current char with the next typed character |
|
||
Scroll One Line Down |
|
||
Scroll One Line Up |
|
||
Search for the Next Occurance of the Word at the Current Cursor Position |
|
||
Search for the Previous Occurance of the Word at the Current Cursor Position |
|
||
Start Change Text Operation |
|
||
Start Delete Text Operation |
|
||
Start Yank Text Operation |
|
||
Swap the current character's case. |
|
||
Undo |
|
||
Enter Search Backwards |
|
||
Enter Search Forward |
|
||
Find Next Pattern |
|
||
Find Previous Pattern |
|
||
Find the Character Typed, After Cursor in Current Line |
|
||
Find the Character Typed, Before Cursor in Current Line |
|
||
Decrease Line Indent |
|
||
Increase Line Indent |
|
||
Jump to Matching Brace |
|