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

edtext editor: usage

back_to_top

COMMANDS
- address
- print
- edit
- marks
- files
- searching
- important
SCRIPTING
TODO
- LEARN
SEE ALSO

back_to_top

[range]command

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
/pattern/ : /sometext/

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 rangeafter target range. (Eg.: 4m5)
t : copy (transfer): copy source rangeafter target range. (Eg.: 4t6)
j : join: join addressed lines. (Eg.: 4,5j)

kl : mark an rangewith a lower-case letter. (Eg.: 4ka)
'l : set current rangeto the rangemarked as l. (Eg.: 'a > will set current rangeto 4)

e [filename] : edit file, if no file is specified it reloads the current file.
E : same as e but discards changes if any.
[range]w [file] : writes to file, if no filename is specified, writes the current file, if rangeis specified, writes the rangeto current/specified filename. If the file exists, it's overwritten.
[range]W [file] : same as w but appends to filename if the file exists.
% : represents the current file.
f : sets/shows the current filename.

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

It's important to always have the . and w on any interactive commands.

To add a . on a script without ending the input, enter \. and then substitute the \ :
,s@^\\.$@.@

$ ed script
a
a
this line is appended
\.
w
.
,s@^\\.$@.@
w
q
$ cat script
a
this line is appended
.
w
$ cat test.txt
line 1
$ ed - test.txt < script
$ cat test.txt
line 1
this line is appended

back_to_top

back_to_top

back_to_top

ed(1)

<ed.oh>

back_to_top

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

Created:2025-10-03|Updated:2025-10-06 OpenBSD linux