Command: edlin

  The edlin program is a small line editor, written for FreeDOS as a
  functional clone of the old MS-DOS program edlin. Its main job is
  to create BATCH-FILES and other small text files. It differs from MS
  edlin in that first, it is free software, and second, the user inter-
  face is slightly different in a few places. The reason for the diffe-
  rence is so that the user does not have to type in control characters
  mandated by MS edlin's syntax.

INVOKING EDLIN

  The edlin program is invoked either by itself:
    edlin
  or with a filename that's initially read in:
    edlin file

EDLIN'S INTERNAL COMMANDS

  In the following command lists:
    The [ and ] brackets represent optional values.
    The # symbol represents a line number, which can be one of several
    possible values:
    -  A string of digits as a literal line number, such as 12 for
       line 12.
    -  A period "." as the current line in the file.
    -  A dollar sign "$" as the last line in the file.
    -  A number "#" as the line number just after the last line in the
       file.
    -  A +n or -n as a count added or subtracted from a line number.
       This is useful for relative line addressing, such as .+1 for the
       line after the current line.

  The $ symbol represents a string of characters. Strings 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
  \.    - Period
  \\    - 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.

  The edlin program supports the following syntax:

# - 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.

[#],[#],#,[#]c - COPY A RANGE OF LINES

This command copies a block of consecutive lines to another location in
the buffer. The parameters are, in order:

  1. The first line you want to copy (default = current line).
  2. The last line you want to copy (default = 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 = 1).

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

[#][,#]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."

[#]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 . (period) 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.

[#][,#]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.

[#],[#],#m - 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.

[#][,#]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."

[#][,#][?]r$,$ - 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.

[#][,#][?]s$ - 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.

[#]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.

[#]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.

Author / Maintainer

Gregory Pietsch, gpietsch@comcast.net

Examples:

  edlin c:\config.sys  Opens the file config.sys for editing.
  edlin                If no file is specified, edline begins with a
                       blank document.
  I want to enter and save four sentences, one below the other.

  This is sentence four.
  This is sentence three.
  This is sentence three.
  This is sentence one.

  (from edlin's * prompt, with an empty buffer...)

  i
  This is sentence four.
  This is sentence three.
  This is sentence three.
  This is sentence one.
  .

  Now I want to save these four sentences in a .txt file at C:\test.txt

  wc:\test.txt

  Then I find out that the third sentence is wrong (correct: This is 
  sentence two). How to correct and to save it?

  3rthree,two
  wc:\test1.txt

  Then I want to add a fifth sentence at the beginning (This is sentence
  five). How to add it?

  1i
  This is sentence five.
  .
  wc:\test2.txt

  I want to see if everything is correct.

  l

  I want to exit.

  q

See also:

  batch files
  blocek
  edit
  ospedit

  Copyright © Gregory Pietsch, gpietsch@comcast.net
  Updated in 2023 by W. Spiegl.

  This file is derived from the FreeDOS Spec Command HOWTO.
  See the file H2Cpying for copying conditions.