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:
-
Normal: navigation and editing.
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.
-
Input: entering text.
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.
-
Visual: visual selection of text with
navigation keystrokes.
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.
-
Command-line: running vi/ex commands.
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:
- edit
- exit
- help
- next
- previous
- quit
- set
- splitview
- undo
- write
- wq
- xit
- number <line number>
- <range>s/<search
string>/<substitution>/[g|i|I]
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.
Vi-specific key bindings
Vi: Cancel
|
|
Vi: Close the Current Buffer Without Saving
|
Z, Q
|
Vi: Cut One Character
|
|
Vi: Cut One Character to Left
|
|
Vi: Cut Whole Line and Enter Insert Mode
|
|
Vi: Cut to End of Line and Enter Insert Mode
|
|
Vi: Delete the Current Character and Enter Insert Mode
|
|
Vi: Deletes from cursor to end of line.
|
|
Vi: Enter Insert Mode
|
|
Vi: Enter Insert Mode after the Cursor Position
|
|
Vi: Enter Insert Mode at Start of the Line
|
|
Vi: Enter Insert mode at the End of the Current Line
|
|
Vi: Enter command mode
|
|
Vi: Enter visual block mode
|
|
Vi: Enter visual character mode
|
|
Vi: Enter visual line mode
|
|
Vi: Go to Next Line
|
|
Vi: Go to Previous Line
|
|
Vi: Goto Line
|
|
Vi: Join current and next lines
|
|
Vi: Move Left One Character
|
|
Vi: Move One Word Left
|
|
Vi: Move Right One Character
|
|
Vi: Move To End of Word To Right
|
|
Vi: Move To Start of Word To Right
|
|
Vi: Move one page down
|
|
Vi: Move one page up
|
|
Vi: Move one word left, past any punctuation
|
|
Vi: Move one word right, past any punctuation
|
|
Vi: Move to Beginning of Line (first visible char/first
column)
|
|
Vi: Move to Beginning of the Current Line
|
|
Vi: Move to Beginning of the Previous Line
|
|
Code Browser
Debugger
Clear All Breakpoints
|
|
Disable/Enable Breakpoint
|
|
New Session
|
|
Run Script
|
|
Run to Cursor
|
|
Show Current Statement
|
|
Start
|
|
Start/Find/Hide Default Interactive Shell
|
|
Step In
|
|
Step Out
|
|
Step Over
|
|
Stop
|
|
Editor
Back
|
|
Backspace
|
|
Beginning of Line (first visible char/first column)
|
|
Cancel AutoComplete
|
|
Close Current Buffer
|
|
Copy
|
|
Cut
|
Ctrl+X
|
Shift+Delete
|
Ctrl+Shift+X
|
|
Delete
|
|
Delete Word Left
|
|
Delete Word Right
|
|
End of Line
|
|
Go to End of Document
|
|
Go to End of word
|
|
Go to Line...
|
|
Go to Next Bookmark
|
|
Go to Next Line
|
|
Go to Previous Bookmark
|
|
Go to Previous Line
|
|
Go to Top of Document
|
|
Insert Abbreviation Snippet by Name
|
|
Insert Newline
|
|
Insert Newline (align with current line)
|
|
Insert Newline (continue comments)
|
|
Insert Newline (no favors)
|
|
Insert Next Key as Literal Character
|
|
Join current and next lines
|
|
Move Back Part of Word
|
|
Move Forward Part of Word
|
|
Move Left One Character
|
|
Move One Character Right
|
|
Move One Word Left
|
|
Move One Word Right
|
|
Page Down
|
|
Page Up
|
|
Paste
|
|
Paste and Select
|
|
Redo
|
|
Reflow paragraph(s)
|
|
Remove All Bookmarks
|
|
Repeat next keystroke N times
|
|
Scroll One Line Down
|
|
Scroll One Line Up
|
|
Select All
|
|
Select Next Character
|
|
Select Next Word
|
|
Select Page Down
|
|
Select Page Up
|
|
Select Previous Character
|
|
Select Previous Word
|
|
Select Rectangular Next Character
|
|
Select Rectangular Page Down
|
|
Select Rectangular Page Up
|
|
Select Rectangular Previous Character
|
|
Select Rectangular to Beginning of Line (first char/first
column)
|
|
Select Rectangular to End of Line
|
|
Select Rectangular to Next Line
|
|
Select Rectangular to Previous Line
|
|
Select to Beginning of Line (first char/first column)
|
|
Select to Beginning of word
|
|
Select to End of Document
|
|
Select to End of Line
|
|
Select to Next Line
|
|
Select to Previous Line
|
|
Select to Top of Document
|
|
Toggle Bookmark
|
|
Toggle Overtype/Insert Mode
|
|
Trigger preceding AutoComplete list or CallTip
|
|
Undo
|
|