vi Keys

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

vi commands:

motion commands
key
action
b
move left one word
e
move word right end
f
find char
h
move left
j
move down
k
move up
l
move right
n
repeat the most recent search, in the same direction
t
find char, no selection
w
move right one word
B
move left one big word
E
word right end one big word
F
find char backwards
G
goto end or line number if prefixed
H
goto first line of the screen
L
goto last line of the screen
M
goto middle line of the screen
N
repeat the most recent search, in the opposite direction from original search
T
find char backwards, no selection
W
move right one big word
/
find next word
?
find previous word
'?
goto marker ?
,
repeat last find char in the reverse direction
space
right one character
0
begin 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
other commands
key
action
m?
mark current line (one letter marker)
p
put after cursor
q
stop macro recording
qx
record macro x
qX
record macro x (appends to x)
r?
replace current character only
s
same as c'space'
u
undo
x
delete
D
delete line right
J
join lines
P
put before cursor
S
same as c_
Q
find tag under cursor (or next tag) and open page
U
internet search of word under cursor, or selected text, using the Search engine
X
delete backwards
Y
yank current line
d
delete selection
dd
delete line
dgg
delete from start of the file until current line
gg
goto begin
y
yank selection
yy
yank line
zc
fold close
zf
fold enable
zo
fold open
zE
fold disable
zM
close all folds
zR
open all folds
ZZ
save 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
tab
indents selection (if on pos 0)
TAB
dedents selection
@x
execute buffer: plays back macro x (register)
@@
execute last buffer: plays back last macro
@Xx@
plays back macro Xx (several characters, starting uppercase)
"x
prepares register x for receiving clipboard for next command instead of unnamed register
"X
see previous, now appends contents of clipboard to register x
mode change commands
key
action
a
insert after cursor
c
changes selection
i
insert before cursor
o
insert after line
v
enter visual mode
A
insert after end of line
C
change to end of line
I
insert at begin
K, ctrl v
enter visual block mode
O
insert before line
R
replace many chars, enters overtype mode
V
enter visual line mode
ESC
escape goes back to normal mode
control char commands
key
action
ctrl b
page backward
ctrl d
page scroll down
ctrl e
scroll down
ctrl f
page forward
ctrl g
display information
ctrl h
delete back
ctrl j
increment word under cursor
ctrl l
decrement word under cursor
ctrl m
line down
ctrl p
line up
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 t
jumps to previous tag
ctrl u
page scroll up
ctrl v
find next tag and open page
ctrl w
go back to page active before Q
ctrl y
scroll up
ctrl ]
as Q
vim commands
key
action
ga
show ascii value
gd
jumps to ctags
gf
opens file under cursor
g*
find next word under cursor
g#
find previous word under cursor
gt
goes to next tab
gu
motion change to lowercase
gU
motion change to uppercase
g~
motion toggle case

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. Also, it can be prefixed by the g character to support some vim commands.

[buffer]

name
purpose
explanation
.
insert register
last inserted text
0
yank register (or unnamed buffer)
last yank value
1 - 9
delete registers
queue of 9 last deleted values
a - z
standard registers
normal register
*
clipboard register
contents of clipboard
%
filename register
current filename
_
black hole register
anything written to it is not kept

Calculation mode

operator
description
+
add
-
subtract
*
multiply
/
divide
<
shift left
>
shift right
.
current line
$
line count
%
modulo
|
bitwise or
&
bitwise and
^
bitwise xor

You can also insert contents of markers, or of registers, or use parenthesis to group expressions.

ex commands:

command
keys
action
abbreviate
:ab[breviate] [lhs rhs]
Abbreviate lhs for rhs, or shows current abbreviations. An abbreviation is used in insert-mode.
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[ppend]
Enter ex text input mode; the input text is placed after the specified line.
arguments
:ar[rgs]
Shows command line arguments, if provided
change
:[2addr]c[hange]
The input text replaces the specified lines
change directory
:chd[ir] cd
Change the current working directory to directory
close
:close
Closes current document
copy
:[2addr]co[py] 1addr
:[2addr]t 1addr
Copy the specified lines after the specified destination line
de
:de debug
Performs debug action, as available in debug menu from wex-menus.xml
delete
:[2addr]d[elete][buffer]
Delete the specified lines into a buffer (defaulting to the unnamed buffer)
edit
:e[dit] [+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). You can also specify wildcards like ? or * to open multiple files.
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.
execute
:[2addr]@buffer
For each line executes the buffer.
file
:f
shows filename and state
global
:[2addr]g[lobal]/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. Addresses are constructed as follows: - The character '.' (period) shall address the current line. - The character '$' shall address the last line of the edit buffer. - The positive decimal number n shall address the nth line of the edit buffer. - The address "'x" refers to the line marked with the mark name character 'x', which shall be a lowercase letter from the portable character set, the backquote character, or the single-quote character. It shall be an error if the line that was marked is not currently present in the edit buffer or the mark has not been set. Lines can be marked with the ex mark or k commands, or the vi m command. - A regular expression enclosed by slash characters ( '/' ) shall address the first line found by searching forwards from the line following the current line toward the end of the edit buffer and stopping at the first line for which the line excluding the terminating newline matches the regular expression. As stated in Regular Expressions in ex, an address consisting of a null regular expression delimited by slash characters ( "//" ) shall address the next line for which the line excluding the terminating newline matches the last regular expression encountered. In addition, the second slash can be omitted at the end of a command line. If the wrapscan edit option is set, the search shall wrap around to the beginning of the edit buffer and continue up to and including the current line, so that the entire edit buffer is searched. Within the regular expression, the sequence "\/" shall represent a literal slash instead of the regular expression delimiter. - A regular expression enclosed in question-mark characters ( '?' ) shall address the first line found by searching backwards from the line preceding the current line toward the beginning of the edit buffer and stopping at the first line for which the line excluding the terminating newline matches the regular expression. An address consisting of a null regular expression delimited by question-mark characters ( "??" ) shall address the previous line for which the line excluding the terminating newline matches the last regular expression encountered. In addition, the second question-mark can be omitted at the end of a command line. If the wrapscan edit option is set, the search shall wrap around from the beginning of the edit buffer to the end of the edit buffer and continue up to and including the current line, so that the entire edit buffer is searched. Within the regular expression, the sequence "\?" shall represent a literal question-mark instead of the RE delimiter. - A plus or a minus ( '+-' ) followed by a decimal number shall address the current line plus or minus the number. A '+' or '-' not followed by a decimal number shall address the current line plus or minus 1.
goto link
:gt
If text is selected and is a link, goes to link, otherwise goes to link on current line
grep
:grep
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[nsert]
Enter ex text input mode; the input text is placed before the specified line.
join
:[2addr]j[oin]
Joins lines
list
:[2addr]l[ist][flags]
See print
map
:map [alias cmd]
Maps alias to cmd, or shows current maps. The alias is interpreted as follow:
  • It is a number. Use to e.g. overwrite control keys, map 5 WWW results in redefining ctrl-e as WWW.
  • Otherwise. Maps strings to other strings, e.g. map :A :ab results in showing abbreviations after i pressing :A.
mark
:[1addr]ma[rk]character
:[1addr]kcharacter
Marks address with character
move
:[2addr]m[ove] 1addr
Move the specified lines after the specified destination line x
new
:new
New document (dialog)
number
:[2addr]nu[mber][flags] :[2addr]#[flags]
These commands shall be equivalent to the ex command: [2addr] p[rint][count] #[flags]
print
:[2addr]p[rint][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. If the l flag is specified, each line ends with a $ sign.
put
:[1addr]pu[t][buffer]
Append text from the specified buffer (by default, the unnamed buffer) to the specified line
quit
:q[ui] [!]
Quit unless modified, quit forced
read
:[1addr]r[ead] [!][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 [ option[=[value]] ...][nooption ...][option? ...][all]]
If all specified shows all options, otherwise sets, unsets, or queries 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[ubstitute]/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[bbrev] lhs
Unabbreviate lhs
unmap
:unm[ap] lhs
Unmaps lhs
version
:ve[rsion]
Shows version
visual
:vi
Switches to visual mode
write
:[2addr]w[rite] [>>][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[it]
Save and quit
write line
:[1addr]=
Shows line number
yank
:[2addr]ya[nk][buffer]
Copy the specified lines to the specified buffer (by default, the unnamed buffer)

Where:

[1addr] a single line address:

chars
range
.
current line
$
last line
'character
line that contains mark character
line no
line number

[2addr] two addresses specifying an inclusive range of lines:

chars
range
%
entire document
*
visible area
'<,'>
visual (selected) area
[1addr],[1addr]
inclusive range of lines

Set Options

all set commands can be entered as modeline as well, at begin or end of file, boolean options can be switched off by prefixing the option with no, current value can be queried by postfixing by a ?

command
purpose
:set ac
sets auto complete
:set ai
sets auto indentation
:set aw
sets auto write
:set eb
sets error bells
:set el
sets edge line
:set ic
sets ignore case
:set mw
sets match words
:set nu
sets line numbers
:set readonly
sets readonly
:set showmode
sets showing vi mode
:set sm
sets show match
:set sws
sets whitespace
:set ut
sets use tabs
:set wm
sets wrap margin
:set ws
sets wrap scan
:set dir=dir
sets dir
:set ec=no
sets edge column
:set report=no
sets reported lines
:set sw=no
sets indentation
:set sy=lexer
sets lexer
:set ts=no
sets tabstop at every no
:set ve=level
sets verbosity log level to specified level

Find and replace use std::regex ECMAScript regular expressions

character
matches
.
Any character
(
This marks the start of a region for tagging a match.
)
This marks the end of a tagged region.
\int
The result of the submatch whose opening parenthesis is the int-th (int shall begin by a digit other than 0). 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.
\b
This matches a word boudary.
\x
This 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.
[...]
The target character is part of the class, 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 target character is not part of the class. For example, [^A-Za-z] means any character except an alphabetic character.
^
This matches the start of a line (unless used inside a class, 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.