ED(oh) LOCAL ED(oh) ed - text editor: usage TOC COMMANDS - address - print - edit - marks - files - searching - important SCRIPTING TODO - LEARN SEE ALSO COMMANDS [range]command address 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/ print p : print addressed lines. n : print addressed lines with line numbers. l : print addressed lines including control and non-printable characters. edit 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) marks 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) files 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. searching g : search globally for matches. v : search globally for non-matching lines. important 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) SCRIPTING NOTE: 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@^\\.$@.@ example $ 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 TODO - document TIPS split lines LEARN - repeat ed commands - remember last range. - command list - undo command list - learn G SEE ALSO - OpenBSD manpages: ed(1) AUTHORS ohazot(oh) | about(oh) | ohazot.com: https://ohazot.com OpenBSD 7.7 linux| Created:2025-10-03|Updated:2025-10-18| ED(oh)