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:
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]
Calculation mode
You can also insert contents of markers, or of registers, or use parenthesis to group expressions.
ex commands:
- : 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
:[2addr]t 1addr
:[2addr]!command
:[2addr]v/pattern/[commands]
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
- 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.
/r: recursive
- 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.
:[1addr]kcharacter
:print [file]
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.
/r: recursive
r: reverse
u: unique
x,y: use columns
:[2addr]&[options]
:[2addr]~[options]
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.
:prev
Where:
[1addr] a single line address:
[2addr] two addresses specifying an inclusive range of lines:
Text Input Mode
Text input mode can be entered by the append, insert, or change commands; it can be exited (and command mode re-entered) by typing a dot ( '.' ) alone at the beginning of a line. If the input contains a '|' character, any subsequent characters, up to the next newline are used as input text to the command, and text input mode is exited as well. Notice that this behaviour is slightly different from the open group specifications.
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 ?
Find and replace use std::regex ECMAScript regular expressions
Regular expressions will only match ranges within a single line, never matching over multiple lines.