_                    _
  ___ | |__   __ _ _______ | |_
 / _ \| '_ \ / _` |_  / _ \| __|
| (_) | | | | (_| |/ / (_) | |_
 \___/|_| |_|\__,_/___\___/ \__|

edtext editor: usage - OpenBSD ed

-p | specify prompt. Eg.: -p:

[range]command

P | toggle prompt.
q | quit. Warns if the buffer has been modified.
Q | quit regardless of whether any changes have been made to the buffer.
h | explain last error.
H | toggle error explanation.
u | undoes the last command.
= | print total lines.

Most commands require a range on which to be executed. If no range is specified, it defaults to the current range.

Exceptions: u (undo), z (scroll), h (help messages).
n : 6
n,n : 4,5
+ : next line.
- : previous line.
. : current line.
$ : last line.
+n : address at n lines after current line.
-n : address at n lines before current line.
; : from current line to the end.
/pattern/ : next line matching pattern. // repeats last search.
?pattern? : previous line matching pattern. ?? repeats last search.

p : print addressed lines.
n : print addressed lines with line numbers.
l : print addressed lines including control and non-printable characters.

a : append: start adding text after the range. (Eg.: 4a)
i : insert: start adding text before range. (Eg.: 4i)
c : change: change the addressed line. (Eg.: 4c)
d : delete: deletes range. (Eg.: 4d)
m : move: move source range after target range. (Eg.: 4m5)
t : copy (transfer): copy source range after target range. (Eg.: 4t6)
j : join: join addressed lines. (Eg.: 4,5j)

kl : mark an range with a lower-case letter. (Eg.: 4ka)
'l : set current range to the range marked as l. (Eg.: 'a > will set current range to 4)

e [filename] : edit file, if no file is specified it reloads the current file.
E : same as e but discards changes if any.
w [file] : writes file. If file is not specified, it writes the current file.
[range]w [file] : writes specified range to file or current file if no file is specified.
[range]W [file] : same as w but appends to filename if the file exists.
% : represents the current file.
f : sets/shows the current filename.
r [file] : reads file into buffer at the end.
[range]r [file] : reads file into buffer after range.

g : search globally for matches.
v : search globally for non-matching lines.

s : normally, substitution is called with /pattern/, but any character can be used (Eg.: |pattern| or @pattern@).
this is useful when substituting paths or variables.
z[n] : scroll.
- if n is specified, scroll the number of lines specified by n.
- If n is not specified and zn has been run before, remember the number of lines used before.
- if n is not specified and zn has not been run before, scroll the number of lines determined by the terminal size.
- n: add n to show line numbers. (Eg.: z5n)

(back to top)

This document is based on OpenBSD ed, there may be some differences with GNUed.

(back to top)

- Translate to Spanish.
- Update &, repeats the current match s/match/&.
- Update %, repeats last substitution.
- Update in substitution newline, escape with \ and press enter
- Add substitution, sr.
- Substitution, if /re/ is omitted, the last search is used. Regardless of previous substitutions.

(back to top)

ed_examples
OpenBSD manpages: ed(1)
links
- Linux port - OpenBSD ed at GitHub
- GNU ed
- sam - multi-file text editor
- Edbrowse, a Command Line Editor Browser
- man.cat-v ed(1) - Unix First Edition Manual Page
- GNUed Detailed ed (Comparing and Merging Files)

(back to top)

2026-06-02 : Split ed_examples.
2025-11-26 : added split lines.
2025-11-25 : added interactive edits, shell commands and other missing options.
2025-10-03 : Created.

(back to top)

ohazot | about | ohazot.com <admin@ohazot.com>

This document applies to: OpenBSD 7.8 , linux | 2026-06-13