This appendix presents an alphabetical list of ex commands, but first, it describes the syntax of ex commands.
To enter an ex command from vi, use this form:
:[address]command[options]
address is the line number or range of lines that are the object of command. If no address is given, the current line is the object of the command.
In ex command syntax, address can be specified by any of the following:
1,$ | All lines in the file. |
x ,y | Lines x through y. |
x ;y | Lines x through y, with current line reset to x. |
0 | Top of file. |
. | Current line. |
n | Absolute line number n. |
$ | Last line. |
% | All lines; same as 1,$ . |
x-n | n lines before x. |
x+n | n lines after x. |
-[ n ] | One or n lines previous. |
+[ | One or n lines ahead. |
'x | Line marked with x. |
'' | Previous mark. |
/ pat / or ? pat? | Ahead or back to line matching pat. |
In ex command syntax, options might be any of the following:
!
Indicates a variant form of the command, overriding the normal behavior.
count
The number of times the command is to be repeated.
count cannot precede the command, because
a number preceding an ex command is treated
as a line address. d3
deletes three lines beginning with the current line; 3d
deletes line 3.
file
The name of a file that is affected by the command. %
stands for
current file; #
stands for previous file.