How to use edlin

The FreeDOS edlin program is a small line editor as a functional equivalent of MS-DOS edlin. It differs from MS-DOS edlin in that it's free software and the user interface is slightly different in a few places. The reason for the difference is so that the user does not have to type in control characters mandated by MS-DOS edlin's syntax.

Invoking edlin

The edlin program is invoked either by itself:

edlin

or with a filename that's initially read in if it exists or if it is not, treated as a new file:

edlin file

Editor commands

In the following command lists:

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

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

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