Manual / ex
ex(1)
| EX(1) | General Commands Manual | EX(1) |
NAME
ex - edit text with a swap-backed line editor
SYNOPSIS
ex [file]
DESCRIPTION
Ex is the root of a family of editors. Display based editing is the focus of vi(1). On maux, ex and vi share their line-editing engine; ex stores text in a swap file so that the edited text need not fit in a process bank.
The buffer is a copy. Changes do not affect the original file until it is written. The basic addresses and a, i, c, d, p, r, w, s, g, v, m, t, j and = commands are described in ed(1). Type ex commands without vi's leading colon.
Differences from ed. Use # or nu for numbered printing; n is reserved for next-file editing and is not implemented. The default r address is the current line, not end of buffer. Join inserts a space between lines. Bare , and ; mean the current line, not the whole buffer: write 1,$ explicitly for every line. A number after s/// is a count of lines, not an occurrence number.
Command names. A command is named by its letters, as in POSIX ex, and may be shortened to a prefix: append, change, copy (co), delete, edit, global, insert, join, list, mark (ma), move, number (nu), print, quit, read, substitute, undo, vglobal, write, xit, and the one-letter k, t and z. Blanks may precede the name. A word that is none of these is refused, so that cxyz is no longer change: the message is ``word: Not an editor command'' and nothing in the buffer changes. A verb followed by an operand it does not take (2d3, 2=x, 1zx) is refused with ``Trailing characters''. Counts, registers and print flags are not implemented.
Additional commands.
- q, q!
- Quit, refusing unsaved changes unless ! is given.
- wq, x
- Write and quit; x writes only when modified.
- w! file
- Write, overriding the guard against overwriting a different existing file.
- e file, e! file
- Replace the buffer by another file, with or without the unsaved-change guard.
- u
- Undo the last change; another u redoes it. Undo is single-level.
- kx, mark x
- Mark the addressed line with letter x. Use 'x as an address and '' for the previous-context mark.
- ?pattern?
- Search backward, wrapping around. ?? and // reuse the last pattern.
- l
- List text with nonprinting characters made visible.
- z
- Print a window of text.
- &
- Repeat the last substitution.
- !command
- Run a shell command without changing the buffer.
- range!command
- Replace the addressed lines by the command's output.
- r !command, w !command
- Read command output into the buffer, or write the addressed text to a command.
For example, 1,$p prints the buffer and 1,$s/old/new/g replaces every occurrence. Shell commands use sh(1), including its real pipelines and its limitations.
The session uses EX.SWPxx in the working directory. Shell escapes also use temporary command/data files there. Quit normally to allow cleanup.
FILES
/usr/man/EX this page
SEE ALSO
DIAGNOSTICS
Normal completion returns 0; recorded command/file errors cause status 1, and initial working-area failure gives 2. Script-mode errors may be silent: inspect the exit status, not just visible question marks. Interactive ex prints the refusal message; vi shows it, or ``Command failed'' for an error with no message of its own, on the status line until the next key.
BUGS
The line table holds 2048 lines; input lines/commands are bounded to 250 bytes and edited line descriptors to 254. Global commands have at most 250 pending matches. There is no full Berkeley option system, tags, multi-file next list, crash-recovery interface or transition from ex into visual mode. Start vi separately.
| September 19, 2026 | maux |