This document serves as a reference and primer to what commands are available when Editra has Vi Emulation enabled. Vi Emulation Mode is disabled by default but can be enabled in the Preferences Dialog, through Edit > Preferences > Document > Code by default, the editor starts in insert mode, this can be changed to start in Normal mode by default through the same dialog mentioned above.
For those familiar with vim, we'll start with how the Vi(m) emulation in Editra is different from vim:
Generally speaking, most commands accept a repeat parameter.
<repeat><command>
So if x does something, 5x does x five times.
For example, w moves one word forward, and 5w moves 5 words forward.
Some commands take other commands as parameters
<repeat><command><repeat><motion>
| Command | Description |
| h | Moves caret to the left |
| j | Moves caret down |
| k | Moves caret up |
| l | Moves caret to the left |
| i | Enters insert mode |
| a | Enters insert mode after the current character |
| I | Enters insert mode at the start of the indentation of current line |
| A | Enters insert mode at the end of line |
| o | Opens a new line below, auto indents, and enters insert mode |
| O | Opens a new line above, auto indents, and enters insert mode |
| R | Enters replace mode (insert mode with overtype enabled). |
| 0 | Move to start of current line |
| $ | Move to end of current line |
| ^ | Move to the start of indentation on current line. |
| w | Moves to the start of the next word |
| b | Moves (back) to the start of the current (or previous) word. |
| e | Moves to the end of the current (or next) word. |
| WBE | Similar to wbe commands, but words are separated by white space, so ABC+X(Y) is considered a single word. |
| [ | (Editra only) Moves back one word part |
| ] | (Editra only) Move one word part forward |
| { | Goto start of current (or previous) paragraph |
| } | Goto end of current (or next) paragraph |
| ~ | Toggle case of character(s) under caret and move caret across them. |
| u | Undo (repeatable). |
| U | Redo (repeatable). |
| rb | Replace character under caret with b |
| x | Delete character under caret |
| X | Delete character before caret (backspace) |
| ma | Bookmark the current position and give it label a |
| `a | Goto position bookmarked with label a |
| 'a | Goto line bookmarked with label a |
| H | Goto first visible line |
| M | Goto the middle of the screen |
| L | Goto last visible line |
| zt | Scroll view so current line becomes the first line |
| zz | Scroll view so current line is in the middle |
| zb | Scroll view so current line is at the bottom (last line) |
| G | Goto last line, or line number (eg 12G goes to line 12) |
| gg | Goto first line in file |
| fx | Find char x on current line and go to it |
| tx | Similar to fx, but stops one character short before x |
| Fx | Similar to fx, but searches backwards |
| Tx | Similar to tx, but searches backwards |
| ; | Repeat last find motion |
| , | Repeat last find motion, but in reverse |
| * | Find next occurance of identifier under caret or currently selected text |
| # | Similar to * but backwards |
| | | Jump to column (specified by the repeat parameter). |
| J | Join this line with the one(s) under it. |
| p | Paste text, if copied text is whole lines, pastes below current line. |
| P | Paste text, if copied text is whole lines, pastes above current line. |
| y | Yank (copy). See below for more. |
| d | Delete. (also yanks) |
| c | Change: deletes (and yanks) then enters insert mode. |
| > | Indent |
| < | Un-Indent |
| . | Repeat last change/insert command (doesn't repeat motions or other things). |
| Y | Yank from current position to the end of line |
| D | Delete from current position to the end of line |
| C | Change from current position to the end of line |
| s | Substitute: deletes character under caret and enter insert mode. |
| S | Change current line (substitute line) |
The commands ydc<> operate on motions.
The general syntax is:
<repeat><command><repeat><motion>A motion is any command that moves the caret to a different location. So H is a motion, but zz is not.
The command is applied over the range of text that would otherwise be moved over. So for instance, yw copies from current position to the start of the next word. y$ copies from current caret position to the end of the line. cf( will delete text from current caret position until the first occurance of ( on the current line. etc.
As a special case, if the motion supplied is the same as the command (which wouldn't really be a motion command), then the operation will work on the current line and the repeat parameter extends it to lines below.
For example, dd will delete the current line. 3yy will copy 3 lines starting with the one under the caret.
Some motions are meant to work with lines, such as 'a which goes to the start of line labeled a, or G which goes to a line number. Operating on these motions operates on whole lines.
> and < operate always on whole lines. so >e will indent the current line, and >j will indent current line and the one below. >> indents current line, and 4 >> indents 4 lines.
Note that 4yy and y4y work the same way.
If there's a selected text, then the change command will operate on the selected text and will not take any motion as a parameter.
One way to select text is via visual mode.
Pressing v while in Normal mode puts you in Visual mode. In this mode, motions extend the current selection.
Some commands will operate on current selection, dcy<>~pi
Note that i will enter insert mode with the selection remaining selected, so whatever you type will overwrite the selected text.
To replace a word with the clipboard content, don't use use dep because when you delete a word using d you also copy it and thus when you paste you'll just paste it agian. Instead, use vep, with ve you'll just select to the end of current word, and p will paste over it and put you back in normal mode.