vi Keys

The following vi keys are supported for navigating and editing, after setting vi Mode in the options. Most keys follow the open group specifations for vi and ex

bmove left one word
emove word right end
ffind char
hmove left
jmove down
kmove up
lmove right
nrepeat the most recent search, in the same direction
tfind char, no selection
wmove right one word
Eword right end (same as e)
Ffind char backwards
Ggoto end or line number if prefixed
Hgoto first line of the screen
Lgoto last line of the screen
Mgoto middle line of the screen
Nrepeat the most recent search, in the same direction
Tfind char backwards, no selection
/find next word
?find previous word
'?goto marker ?
,repeat last find char in the reverse direction
spaceright one character
0begin of line
[move to previous "{...}" section
]move to next "{...}" section
(paragraph up, in visual mode adds to selection (same as {)
)paragraph down, in visual mode adds to selection (same as })
{paragraph up, in visual mode adds to selection
}paragraph down, in visual mode adds to selection
^begin of line
+move to first character on the next line
|goto column number specified by prefix
-move to first character on the previous line
$end of line
%matching brace, in visual mode selects with matching brace
_next line
;repeat last find char
!see ex :! command
ctrl bpage up
ctrl fpage down
ctrl pscroll up
ctrl qscroll down
m?mark current line (one letter marker)
pput after cursor
qstop macro recording
qxrecord macro x
qXrecord macro x (appends to x)
r?replace current character only
uundo
xdelete
Bfind previous tag and open page
Ddelete line right
Jjoin lines
Nrepeat the most recent search, in the opposite direction from original search
Pput before cursor
Qfind tag under cursor (or next tag) and open page
Sgo back to page active before Q
Tinternet search of word under cursor, or selected text
Wfind next tag and open page
Xdelete backwards
Yyank current line
ddelete selection
dddelete line
dggdelete from start of the file until current line
gggoto begin
yyank selection
yyyank line
zcfold close
zffold enable
zofold open
zEfold disable
zMclose all folds
zRopen all folds
ZZsave and quit
.repeat last action
~toggle case
*next occurrence of word under cursor, or selected text
#previous occurrence of word under cursor, or selected text
>increase indent for current line, selection or visual area
<decrease indent for current line, selection or visual area
tabindents selection (if on pos 0)
TABdedents selection
@xexecute buffer: plays back macro x (register)
@@execute last buffer: plays back last macro
@Xx@plays back macro Xx (several characters, starting uppercase)
"xprepares register x for receiving clipboard for next command instead of unnamed register
"Xsee previous, now appends contents of clipboard to register x
ainsert after cursor
iinsert before cursor
oinsert after line
venter visual mode
Ainsert after end of line
cchanges selection
Cchange to end of line
Iinsert at begin
Kenter visual rectangular mode
Oinsert before line
Rreplace many chars, enters overtype mode
Venter visual line mode
ESCescape goes back to normal mode
ctrl eincrement word under cursor
ctrl gshows filename and state
ctrl jdecrement word under cursor
ctrl r?inserts contents of register ?
ctrl r%inserts contents of % register, or copies contents to clipboard if not in insert mode
ctrl r=enters register calculation mode
ctrl [jumps to previous tag
ctrl ]jumps to the tag underneath the cursor, or next tag
abbreviate :ab [lhs rhs] Abbreviate lhs for rhs
adjust window :[1addr]z[type][count][flags] Print the specified line with context. If count is not specified, it default is 2. Type can be:
- : The specified line shall be decremented by the following value: (((number of "-" characters) x count) -1)
+ : The specified line shall be incremented by the following value: (((number of "+" characters) -1) x count) +
^ : The specified line shall be decremented by the following value: (((number of "^" characters) +1) x count) -1
= : Embed context into lines of 40 - characters, with (count -1) / 2 around match
. : show context with (count -1) / 2 around match
append :[1addr]a Enter ex text input mode; the input text is placed after the specified line.
arguments :ar Shows command line arguments, if provided
change :[2addr]c The input text replaces the specified lines
close :close Closes current document
copy :[2addr]t 1addr Copy the specified lines after the specified destination line
de :de debug Performs debug action, as available in debug menu from menus.xml
delete :[2addr]d[buffer] Delete the specified lines into a buffer (defaulting to the unnamed buffer)
edit :e [+command][file] If no file is specified shows select file dialog, otherwise edits file and performs specified command on it (you can use tab key for autocomplete).
escape :!command
:[2addr]!command
If no lines are specified executes command and shows output. If lines are specified, they are passed to the program as standard input, and the standard output and standard error of the program replaces those lines in the edit buffer.
file :f shows filename and state
global :[2addr]g/pattern/[commands]
:[2addr]v/pattern/[commands]
If pattern and commands are empty: remove all markers
otherwise if commands are empty: mark lines containing pattern
otherwise executes all commands for each line matching pattern, commands separated by |, or (for v) executes all commands for each line not matching pattern
goto :[1addr] Goto specified address
goto link :gt If text is selected and is a link, goes to link, otherwise goes to link on current line
grep :grep [match][extension][folder][options] If nothing specified shows find in files dialog, otherwise greps for match in folder matching file extension using options:
/r: recursive
help :help Shows help
indent :[2addr][>|<] Increase, decrease indent for range
insert :[1addr]i Enter ex text input mode; the input text is placed before the specified line.
join :[2addr]j Joins lines
mark :[1addr]kcharacter Marks address with character
map :map[new<command] Maps new command to command, or shows current maps.
  • String map. Maps strings to other strings
  • Key map. Map an ascii key to a sequence
  • Alt key map. Map an alt key to a sequence
  • Control key map. Map a control key to a sequence, for control chars outside normal range
move :[2addr]m 1addr Move the specified lines after the specified destination line x
new :new New document (dialog)
print :[2addr]p[flags]
:print [file]
Write the addressed lines
If the # flag is specified, each line is preceded by line number.
The second synopsis shows print dialog if file is not spcified, otherwise prints file.
put :[1addr]pu[buffer] Append text from the specified buffer (by default, the unnamed buffer) to the specified line
quit :q [!] Quit unless modified, quit forced
read :[1addr]r [!][file] If ! not specified insert contents of file below cursor, otherwise inserts output or running file command below cursor
register :reg Shows registers (buffers) and variables from calculation mode
sed :sed [match replace][extension][folder][options] If nothing specified shows replace in files dialog, otherwise replaces match by replace in folder matching file extension using options:
/r: recursive
set :set [options] If options not specified shows options dialog, otherwise sets specified options
sort :[2addr]S[options] Sorts range by lines using options:
r: reverse
u: unique
x,y: use columns
source :so file Executes all commands from file
substitute :[2addr]s/pattern/repl/[options]
:[2addr]&[options]
:[2addr]~[options]
Replace the first instance of the pattern pattern by the string repl on each specified line. If both pattern and repl are not specified or are empty (for example, "//" ), the last s command is repeated. If only pattern is not specified or is empty, the last regular expression used in the editor is used as the pattern.
Supported options:
i: ignore case
c: ask for confirmation
g: global, otherwise only first match on line
When substituting you can use:
  • & or \0 to represent the target,
  • \U to convert to uppercase,
  • \L to convert to lowercase,
  • $ to match a line end, e.g. %s/$/EOL appends the string EOL at the end of each line.
  • ~ to match against a previous replacement string.
Merging is not yet possible using a \n target, you can create a macro for that.
syntax :syntax options Use syntax highlighting, options are on or off
tab :n
:prev
Next or previous
tag :ta tag Jumps to tag
unabbreviate :una lhs Unabbreviate lhs
unmap :unm lhs Unmaps lhs
version :ve Shows version
write :[2addr]w [>>][file] If no lines are specified, the entire file is used. If the >> argument is specified, and the file already exists, the lines are appended to the file instead of replacing its contents.
write and exit :x Save and quit
write line :[1addr]= Shows line number
yank :[2addr]y[buffer] Copy the specified lines to the specified buffer (by default, the unnamed buffer)

Each motion command can be prefixed with a multidigit number, that takes care of repeating that command the number specified, and by a c, d, y character that changes, deletes or yanks the specified motion.

Where:

[1addr]

A single line address
.current line
$last line
'characterline that contains mark character
line noline number

[2addr]

Two addresses specifying an inclusive range of lines.
%entire document
*visible area
'<,'>visual (selected) area
[1addr],[1addr]inclusive range of lines

[buffer]

.insert registerlast inserted text
0yank register (or unnamed buffer)last yank value
1 - 9delete registersqueue of 9 last deleted values
a - zstandard registersnormal register
*clipboard registercontents of clipboard
%filename registercurrent filename
_black hole registeranything written to it is not kept

[Calculation mode]

+add
-subtract
*multiply
/divide
<<shift left
>>shift right
.current line
$line count
%modulo
|bitwise or
&bitwise and
^bitwise xor
XXX=2assigns to variable XXX
You can also insert contents of markers, or of registers, or use parenthesis to group expressions.

[Edit Options]

all set commands can be entered as modeline as well, at begin or end of file
:set ac toggles auto complete
:set ai toggles auto indentation
:set el toggles edge line
:set ic toggles ignore case
:set mw toggles match words
:set nu toggles line numbers
:set re toggles regular expression
:set sm toggles showing vi mode
:set ut toggles use tabs
:set wl toggles wrap line
:set ws toggles whitespace
:set ec=no sets edge column
:set rp=no sets reported lines
:set sw=no sets indentation
:set sy=lexer sets lexer
:set ts=no sets tabstop at every no

Replace uses regular expressions from std::regex or from scintilla (if compiler flag NO_CXX11_REGEX is defined, which is the default):

.Matches any character
\(This marks the start of a region for tagging a match.
\)This marks the end of a tagged region.
\nWhere n is 1 through 9 refers to the first through ninth tagged region when replacing. For example, if the search string was Fred\([1-9]\)XXX and the replace string was Sam\1YYY, when applied to Fred2XXX this would generate Sam2YYY. \0 refers to all of the matching text.
\<This matches the start of a word using Scintilla's definitions of words.
\>This matches the end of a word using Scintilla's definition of words.
\xThis allows you to use a character x that would otherwise have a special meaning. For example, \[ would be interpreted as [ and not as the start of a character set.
[...]This indicates a set of characters, for example, [abc] means any of the characters a, b or c. You can also use ranges, for example [a-z] for any lower case character.
[^...]The complement of the characters in the set. For example, [^A-Za-z] means any character except an alphabetic character.
^This matches the start of a line (unless used inside a set, see above).
$This matches the end of a line.
*This matches 0 or more times. For example, Sa*m matches Sm, Sam, Saam, Saaam and so on.
+This matches 1 or more times. For example, Sa+m matches Sam, Saam, Saaam and so on.

Regular expressions will only match ranges within a single line, never matching over multiple lines.