.Dd Created:$Mdocdate$ .Dt ohazot_ed .Tg back_to_top .Bd -literal -compact _ _ ___ | |__ __ _ _______ | |_ / _ \\| '_ \\ / _` |_ / _ \\| __| | (_) | | | | (_| |/ / (_) | |_ \\___/|_| |_|\\__,_/___\\___/ \\__| .Ed .Tg menu .Bl -column ".Sy ohazot " ".Sy ohazot " ".Sy ohazot " .It Xr ohazot oh Ta | .Xr docs oh Ta | .Xr about oh Ta .El .Dd Created:2025-10-03|Updated:2025-10-06 .Dt ohazot_ed .Os OpenBSD linux .Nm ed .Nd text editor : usage .Sh TOC .Sx back_to_top .Bl -column -offset indent "Sy It - Sx searching " .It Sx COMMANDS .It - Sx address .It - Sx print .It - Sx edit .It - Sx marks .It - Sx files .It - Sx searching .It - Sx important .It Sx SCRIPTING .It Sx TODO .It - Sx LEARN .It Sx SEE ALSO .El .Sh COMMANDS .Sx back_to_top [range]command .Ss address Most commands require a range on which to be executed. If no range is specified, it defaults to the current range. .D1 Exceptions: u (undo), z (scroll), h (help messages). .Bl -column ".Sy opt " .It n Ta : 6 .It n,n Ta : 4,5 .It /pattern/ Ta : /sometext/ .El .Ss print .Bl -column ".Sy -opt " .It p Ta : print addressed lines. .It n Ta : print addressed lines with line numbers. .It l Ta : print addressed lines including control and non-printable characters. .El .Ss edit .Bl -column ".Sy opt " .It a Ta : append: start adding text after the range. (Eg.: 4a) .It i Ta : insert: start adding text before range. (Eg.: 4i) .It c Ta : change: change the addressed line. (Eg.: 4c) .It d Ta : delete: deletes range. (Eg.: 4d) .It m Ta : move: move source rangeafter target range. (Eg.: 4m5 ) .It t Ta : copy (transfer): copy source rangeafter target range. (Eg.: 4t6) .It j Ta : join: join addressed lines. (Eg.: 4,5j) .El .Ss marks .Bl -column ".Sy opt " .It kl Ta : mark an rangewith a lower-case letter. (Eg.: 4ka) .It 'l Ta : set current rangeto the rangemarked as l. ( Eg.: 'a > will set current rangeto 4) .El .Ss files .Bl -column ".Sy [address]w [address] " .It e [filename] Ta : edit file, if no file is specified it reloads the current file. .It E Ta : same as e but discards changes if any. .It [range]w [file] Ta : 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. .It [range]W [file] Ta : same as w but appends to filename if the file exists. .It % Ta : represents the current file. .It f Ta : sets/shows the current filename. .El .Ss searching .Bl -column ".Sy opt " .It g Ta : search globally for matches. .It v Ta : search globally for non-matching lines. .El .Ss important .Bl -column ".Sy opt " .It s Ta : normally, substitution is called with /pattern/, but any character can be used (Eg.: |pattern| or @pattern@). .D1 this is useful when substituting paths or variables. .It z[n] Ta : scroll. .Bl -dash -compact .It if n is specified, scroll the number of lines specified by n. .It If n is not specified and zn has been run before, remember the number of lines used before. .It if n is not specified and zn has not been run before, scroll the number of lines determined by the terminal size. .It n: add n to show line numbers. (Eg.: z5n) .El .El .Sh SCRIPTING .Sx back_to_top .Pp It's important to always have the . and w on any interactive commands. .D1 To add a \&. on a script without ending the input, enter \e\&. and then substitute the \e\ : .Li ,s@^\e\e\&.$@\&.@ .Ss example .Bd -literal -compact $ ed script a a this line is appended \e\&. w \&. ,s@^\e\e\&.$@\&.@ 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 .Ed .Sh TODO .Sx back_to_top .Bl -dash -compact .It document TIPS split lines .El .Sh LEARN .Sx back_to_top .Bl -dash -compact .It repeat ed commands .It remember last range. .It command list .It undo command list .It learn G .El .Sh SEE ALSO .Sx back_to_top .Ss OpenBSD manpages .Xr ed 1 .Ss files .In ed.oh .Sh AUTHORS .Sx back_to_top .An -nosplit .Xr ohazot oh | .Xr about oh | .Lk https://ohazot.com ohazot.com .Aq Mt admin@ohazot.com