NAME
        ed - the standard Unix text editor

SYNOPSIS
        ed [file]

DESCRIPTION
        ed is a Lua implementation of the standard Unix text editor.  ed is a line-oriented text editor.  It is used to create, display, modify, and otherwise manipulate text files interactively.  This version is more similar to red, the restricted editor, except that it can edit files anywhere in the filesystem.

        ed will start edit by reading in 'file' if given.

COMMANDS
        All ed commands are single characters, though some require additional parameters.  At most one command is allowed per line.

        (.)a
            Appends text to the buffer after the addressed line.  The address '0' (zero) is valid for this command; it places the entered text at the beginning of the buffer.  Text is entered in input mode.  The current address is set to the address of the last line entered or, if there were none, to the addressed line.

        (.,.)c
            Changes lines in the buffer.  The addressed lines are deleted from theh buffer, and text is inserted in their place.  Text is entered in input mode.  The current address is set to the address of the last line entered or, if there were none, to the new address of the line after the last line deleted; if the lines deleted were originally at the end of the buffer, the current address os set to the address of the new last line; if no lines remain in the buffer, the current address is set to zero.

        (.,.)d
            Deletes the addressed lines from the buffer.  The current address is set to the new address of the line after the last line deleted; if the lines deleted were originally at the end of the buffer, the current address is set to the address of the new last line; if no lines remain in the buffer, the current address is set to zero.

        eFILE
            Edits FILE, and sets the default filename.  If FILE is not specified, then the default filename is used.  Any lines in the buffer are deleted before the new file is read.  The current address is set to the address of the last line in the buffer.

        fFILE
            Sets the default filename to FILE.  If FILE is not specified, then the default filename is printed.

        (.)i
            Inserts text in the buffer before the addressed line.  The address '0' (zero) is valid for this command; it places the entered tet at the beginning of the buffer. Text is entered in input mode.  The current address is set to the address of the last line entered or, if there were none, to the addressed line.

        (.,.)l
            List command.  Prints the addressed lines unambiguously.  The end of each line is marked with a '$', and every '$' character within the text is printed with a preceding backslash.

        (.,.)p
            Prints the addressed lines.

        P
            Toggles the command prompt on and off.  The default prompt is an asterisk.

        q
            Quits 'ed' unconditionally.  Unwritten changes are discarded without warning.
        
        w

        (1,$)s/RE/REPLACEMENT/
            Substitute command.  Replaces text in the addressed lines matching a Lua pattern RE with REPLACEMENT.

            RE and REPLACEMENT may only be delimited by the / (forward-slash) character.  If the last delimiter is omitted, the command will not execute.

            An unescaped %n in REPLACEMENT will match the nth occurrence of the pattern matched by RE in any given line.

        (1,$)wFILE
            Writes the addressed lines to FILE.  Any previous contents of FILE are lost without warning.  If there is no default filename, then the default filename is set to FILE, otherwise it is unchanged.  If no filename is specified, then the default filename is used.

EXAMPLES
        Command parameters should be given without spaces - for example, w example becomes wexample.

        1,5s/old/new/
            Substitute old for new on lines 1 through 5.

        ,p
            Print the whole buffer.

COPYRIGHT
        Original design and implementation (c) 1969 Ken Thompson/Bell Labs. Lua implementation (c) 2020 Ocawesome101 under the GNU GPLv3.

        Command descriptions partially taken from the Texinfo manual page on ed.  Copyright (C) 1993, 1994, 2006-2020 Free Software Foundation, Inc.

SEE ALSO
        led(1), fled(1), vled(1), editor(3)