EDLIN(1)

NAME
edlin - FreeDOS line-oriented text editor

SYNOPSIS
edlin [filename]

DESCRIPTION
The FreeDOS edlin program is a small line-oriented text editor. Unline screen-based editors, edlin does not display the text being edited at all times, instead only showing parts of it upon the user's request.

When invoked, edlin presents the user a command line allowing them to manipulate the text by applying operations on the specified lines of the text file. All commands operate on whole lines or ranges of lines.

In general, the structure of an edlin command is as follows:

    [LINE[,LINE...]]COMMAND[PARAMETERS...]

A line number can be one of the following:

A sequence of digits as a literal line number, such as 12 for line 12.
A full stop (.), meaning the current line in the file.
A dollar sign ($), meaning the last line in the file.
A hash sign (#), meaning the line number just after the last line in the file.
A number added or subtracted from a line number (+n or -n). This is useful for relative line addressing, such as .+1 for the line after the current line.

String parameters may be enclosed in either single or double quotes, and may contain the following escape sequences:

\a: Alert character
\b: Backspace character
\e: Escape
\f: Form feed
\t: Horizontal tab
\v: Vertical tab
": Double quote
': Single quote
.: Full stop
\: Backslash
\xXX: Hexadecimal value, where each X is a hexadecimal digit (0 to F, uppercase or lowercase)
\dNNN: Decimal value, where each N is a decimal digit (0 to 9)
\OOO: Octal value, where each O is an octal digit (0 to 7)
\^C: Control character, such as \^J for the literal "control J" (linefeed) character.

COMMAND SYNOPSIS
The edlin program supports the following editor commands:

#: Edit a single line
    The edlin program outputs the single line indicated by the number, and the next inputted line replaces the outputted line in the file.

a: Append to the file
    This command is equivalent to $+1i

[LINE],[LINE],LINE,[NUMBER]c: Copy a range of lines
    Copy a range of consecutive lines to another location in the buffer. The parameters are, in order:

    1. The first line you want to copy (default is the current line)
    2. The last line you want to copy (default is the current line)
    3. The line before which you want to insert the block of lines
    4. The number of times you want to copy the block (default is 1)

    After copying lines, use the l (list) command to see the new line numbers.

[LINE][,LINE]d: Delete a range of lines
    Delete a block of consecutive lines from the buffer. The parameters are the first and last line of the block to be deleted.

    If you omit the first parameter, delete the block from the current line to the line specified in the second parameter (be sure to include the comma).

    If you omit the second parameter, delete only the line specified in the first parameter.

    Omitting both parameters deletes the current line.

e filename: Save and exit
    This command is equivalent to w filename followed by q

    This verifies whether the user actually wants to quit before doing so. To quit, answer the "Abort edit (Y/N)?" prompt with "yes."

[LINE]i: Insert lines
    Enter insert mode. Its parameter is the line number before which you want to insert lines.

    While entering text, you can use the escape sequences from above.

    To exit insert mode, type . (full stop) on a line by itself. (If you need a line with just a period, you need to enter it as \.)

    After exiting insert mode, the line after the inserted text becomes the current line, unless the insertion was appended to the end of the buffer, in which case the last line in the buffer becomes the new current line.

[LINE][,LINE]l: List lines
    List the lines of text to the screen. If you omit the first parameter, start showing text starting at 11 lines before the current line.

    If you omit the second parameter, shows a screen of text beginning with the line specified in the first parameter.

    If you omit both parameters, show a screen of text starting at 11 lines before the current line.

    If the number of lines to show is longer than the number of lines on the screen, edlin will prompt after each screen.

[LINE],[LINE],LINEm: Move lines
    Move a block of text to the line before the number specified in the third parameter. It is similar to copying then deleting the original block.

[LINE][,LINE]p: Print lines
    Similar to the l (list) command except that the default parameters starts at the current line instead of 11 lines before it.

q: Quit
    Quit the program.

    This verifies whether the user actually wants to quit before doing so. To quit, answer the \"Abort edit (Y/N)?\" prompt with \"yes.\"

[LINE][,LINE][?]rSTRING,REPLACEMENT: Replace string
    Replace all occurrences of the first string with the second between the two lines specified.

    If you omit the first parameter, start replacing at the line after the current line.

    If you omit the second parameter, stops replacing text at the last line of the buffer.

    If you include the ? (question mark), edlin will print a confirmation message before replacing text.

[LINE][,LINE][?]sSUBSTRING: Search for a substring
    Search for the first line containing the specified substring.

    If you omit the first parameter, start searching from the current line.

    If you omit the second parameter, stop the search at the end of the buffer.

    If you include the ? (question mark), edlin will print a confirmation message. Responding "no" to the confirmation message continues the search; "yes" ends the search.

    If the search found the substring, the current line will be set to the line where the search ended.

[LINE]t filename: Transfer a file
    Insert the contents of a file before the specified line number.

    If you omit the line number, insert before the current line.

[LINE]w filename: Write the file
    Write the first # lines in the buffer to the specified file.

    If you omit the number parameter, write all the lines in the buffer to the file.

?: Print short help notice

EXIT STATUS
edlin aborts and returns non-zero if the standard input is closed when it expects a command, e.g. if the user presses Control-D at the command prompt.

HISTORY
The FreeDOS edlin was developed by Gregory Pietsch in 2003.

The original edlin was created by Tim Paterson in 1980, inspired by the CP/M context editor ED, which itself was distantly inspired by the Unix ed line editor.

NOTES
Unlike the original edlin, the FreeDOS edlin uses a comma (,) as a parameter separator for the "replace" command (r) instead of the DOS end-of-file control character (Control-Z).

The command l, when specified in upper case (L) is synonymous to p and starts printing from the current line.

COPYRIGHT
Copyright (C) 2003-2024 Gregory Pietsch

Copyright (C) 2025 Andrej Shadura

SEE ALSO
ed(1)