Vi Emulation


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.


  • When in Insert mode, you can enter Normal mode by pressing Esc or ctrl-[
  • When in Normal mode, you can enter Insert mode by pressing i or another command (more details below).
  • There's also a (somewhat limited) Visual mode, entered by pressing v.

Normal mode commands:

For those familiar with vim, we'll start with how the Vi(m) emulation in Editra is different from vim:

  • No support for iw motions (such as diw deleting the word under caret).
  • Sentence motions are not supported ( and ).
  • Redo is U, not ctrl-R. Generally speaking, ctrl is not handled at all in Editra's normal mode. This is intentional because the user can customize what ctrl-<Key> commands do, and we don't want to interfere with that. The only exception being ctrl-[ taking you to Normal mode.
  • "a is its own command, and it switches to register a. It's not a command prefix. When you switch to register a, it continues to be the current register until you switch again to a different register.
  • The " register is an alias to the system clipboard (it's handled as a special case), and it's also the default register. There's no support for + or * registers.
  • Not much recognition of words as objects. In vim, cw tries to be smart and behave just like ce. However, in Editra, cw deletes upto the next word and enters insert mode; it's not equivalent to ce.
  • The [ and ] keys are assigned to move across word parts: words inside identifiers. SuchAsWordSeparatedByCaps or_words_separated_by_underscores. As a result, whatever stuff vim does using [] is not supported in Editra's Normal mode. There's a possibility this might change in the future.
  • /? Open the find-bar in Editra. For the time being, ? is not different from / at all.
  • Repeating search with n and N is not supported (at least not yet).
  • The + and - as moving up/down the line are not supported.
  • The % motion is not implemented (at least not yet).
  • The auto-format operator = is not supported (at least not yet).
  • gf (goto file under cursor) is not supported (at least not yet).
  • Macros in Normal mode are not supported (at least not yet).

Command syntax:

    Generally speaking, most commands accept a repeat parameter.


    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


Description of Commands:

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)

Change commands:

The commands ydc<> operate on motions.

The general syntax is:


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.

Change commands on selection:

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.

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.

Random Hints:

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.