ed is a simple text editor, which can be used where usage of a terminal is not supported, or visual editors (such as vi) are not available. Note that most of content of this page has taken from [ed(1)](/https://man.openbsd.org/ed) man page, with help of @artsi0m on telegram. but this document won't explain ed commands and features completely, please read that. ed has two modes, first one is command mode, which is default mode when you open ed, second one is input mode, which is used for adding text into your file like any other editor. # input mode as mentioned before, input mode is where you change the text directly using stdin of your terminal. below, are few examples of commands can used to start input mode: || border=1 || a || append text the end of file || || i || insert text to current line || || c || change and replace current line || note that you can exit input mode and switching back to command mode using a single dot (.) on a blank line and length of file will shown afterwards. for example: $ ed file i Hello, world. . 14 # basic examples opening a file: $ ed file using a custom prompt: $ ed -p '~' file using ed without noise, suitable for usage on scripts: $ ed -s file # basic ed commands note that you can combine some (if not all?) commands, like wq for writing and quitting. || border=1 || a || append, for adding text into the end of your file (or buffer). || || e || opens first argument as file to edit (!command is accepted). cleans buffer before doing this. if there is no argument, uses default file name (see f). || || E || like e, but won't show warnings about unwritten changes || || f || sets default filename (see f) || || H || prints error explanation for next errors || || h || prints error explanation for the last error || || n || same as p, but shows with line numbers. || || p || means print, to show the file you are editing. || || P || toggles prompt, enabled only when you've used -p while executing ed || || Q || like q, but won't show you a warning about unsaved stuff || || q || quits ed || || u || undo, only saves last thing (this includes undo too, of course) || || r || read from file (or !command), can take a address. (like 9r will open 9th line) || || w || writes buffer into file || || = || works like wc -l || || any number || switches to that line, for example 9 will switch to 9th line of file ( or buffer?) || # advanced ed commands || border=1 || m,nd || deletes mth line until nth line in buffer || || m,nG/re/ || finds and moves on lines which include regular expression re from mth line, until nth line || || m,nj || joins all lines from mth line to nth line || || m.ng/re/command || finds all lines containing re regular expression and executes (ed) command on them. || || s/re/replacements || replaces all all "re"'s with replacements || || m.nV/re/ || like G, but reverse (all lines that does not contain re) || # ed symbols || border=1 || , or %25 || all lines from first line until current line || || ?? || repeats last search done by ?re? || || ?re? || previous line containing regular expression re || || -n or ^n || nth previous line || || - or ^ || previous line || || n || nthn line in buffer || || . || current line || || $ || last line in buffer || || +n || n line upper || || /re/ || next line containing regular expression re || || // || repeats last search done by /re/ || || + || one line upper || || %25 || file name || || 'lc || shows (book?)marked line in buffer (see k command) ||