In the early days of DOS, the standard editor was a no-frills line-editor called Edlin. Tim Paterson wrote the original Edlin for the first version of DOS, then known as 86-DOS, later known as PC-DOS and MS-DOS. Patterson had commented that he intended to eventually replace Edlin, but it wasn’t until a decade later that MS-DOS 5 (1991) replaced Edlin with the full-screen editor Edit.
You probably know FreeDOS as an open source DOS-compatible operating system that you can use to play classic DOS games, run traditional commercial software, or develop embedded systems. FreeDOS has good compatibility with MS-DOS, and the “Base “package group includes utilities and programs that replicate MS-DOS behavior. One classic program is an open source implementation of the ancient Edlin editor; Edlin is released under the GNU General Public License, Version 2.
Edlin, written by Gregory Pietsch, is a well-designed, portable editor. You can even compile Edlin on Linux. As Gregory describes in his free ebook 23 Years of FreeDOS, the top layer parses the input and calls the middle layer, a library called Edlib, which calls string and array handling code to do the dirty work. But aside from its technical merits, I find Edlin very pleasant to use when I want to edit text in an “old-fashioned” way.
FreeDOS 1.3 RC4 includes Edlin 2.18. This is actually an outdated version, but you can download Edlin2.19 from the FreeDOS file archive of Ibiblio. You’ll notice that two files –_edlin-2.19.zip_ — contain the source code, and _edlin-219exe.zip_ is just an executable for DOS. Download the _edlin-219exe.zip_ file and unzip it into your FreeDOS system. I have unpacked my copy in C:\EDLIN.
Edlin needs a little practice to “get into” it, so let’s edit a new file to show some common Edlin actions.
practice
Start editing the file by typing EDLIN, then the name of the file you want to edit. For example, to edit a C programming source file called hello. C, you can type.
C:\EDLIN> edlin hello.c
Here I typed the FreeDOS commands in all lowercase letters. FreeDOS is actually _ case-insensitive, so you can type commands and files in upper or lower case. Typing edlin or edlin or edlin will run the Edlin editor, respectively. Similarly, you can identify the source file as hello.c or hello.c or hello.c.
C:\EDLIN> EDLIN hello. C EDLIN 2.19, copyright (c) 2003 Gregory Pietsch This program comes with ABSOLUTELY NO WARRANTY. It is free software, and you are welcome to redistribute it under the terms of the GNU General Public License -- either version 2 of the license, or, at your option, any later version. hello.c: 0 lines read *Copy the code
Once inside Edlin, you’ll be attracted by a friendly * tip. The interface is fairly minimalist; There are no shiny “menus” or mouse support. Just type a command at the * prompt to start editing, modifying lines, searching and replacing, saving your work, or exiting the editor.
Since this is a new file, we need to add new lines. We’ll do this with the _ insert _ command, typing I at the * prompt. The Edlin prompt will become:, where you will enter your new text. When you are finished adding new text, type a period (.) in the line. .
*i : #include <stdio.h> : : int : main() : { : puts("Hello world"); :} :. *Copy the code
To see the text you have typed so far, use the list command and type L at the * prompt. Edlin will display the number of lines on one screen at a time, assuming there are 25 lines on the screen. But for this short “Hello World “program, the source code fits on one screen.
*l 1: #include <stdio.h> 2: 3: int 4: main() 5: { 6: puts("Hello world"); 7: *} *Copy the code
Did you notice the * on line 7, the last line of the file? That’s a special marker that says where you are in the file. If you insert new text into the file, Edlin will add it to this location.
Let’s update the C source file to return a code to the operating system. To do this, we need to add a line above line 7_. Since that’s where Edlin is marked, we can use I to insert the next text before this line. Don’t forget to stop typing new text by typing. On your own line.
By listing the contents of the file afterwards, you can see that we inserted the new text in the right place, before the closing “curly braces” in the program.
*i : return 0; : . *l 1: #include <stdio.h> 2: 3: int 4: main() 5: { 6: puts("Hello world"); 7: return 0; 8: *} *Copy the code
But what if you need to edit a line in a file? In *, simply enter the line number you want to edit. Edlin only works one line at a time, so you need to retype the entire line. In this case, let’s update the main() function definition to use a slightly different programming syntax. This is on line 4, so type 4 at the prompt and re-type the line in its entirety.
The contents of the file are then listed, showing the updated line 4.
*4 4:*main() 4: main(void) *l 1: #include <stdio.h> 2: 3: int 4:*main(void) 5: { 6: puts("Hello world"); 7: return 0; 8:} *Copy the code
When you have made all the changes you need to make, don’t forget to save the updated file. Type W at the prompt to write the file _ back to _ disk, then use Q to exit Edlin and return to DOS.
*w
hello.c: 8 lines written
*q
C:\EDLIN>
Copy the code
Quick Reference Guide
This walkthrough demonstrates the basics of editing files using Edlin. But Edlin does more than just insert, edit, and save. Here’s a handy cheat sheet that shows all the Edlin functionality, where text stands for a text string, filename is the _ path _ and name of the file, and num is a number (with Represents the current line number, and $represents the last line number).
? |
Display help |
num | Edit a single line |
a |
Append a line below the tag |
[num]i |
Insert a new line before the tag |
[num] [. num]l |
Lists the files (starting 11 lines above the tag). |
[num] [. num]p |
Page (same as the list, but starting at the tag). |
[num]. [num]. num. [num]c |
Copy the line |
[num]. [num]. numm |
Mobile number of rows |
[num] [. num] [? ]s The text |
Search text |
[num] [. num] [? ]r text. text |
Replace text |
[num] [. num]d |
Delete rows |
[num]t The file name |
Transfer (Inserts the contents of a new file at the tag |
[num]w [name of the file] |
Write the file to disk |
q |
Exit Edlin |
e [name of the file] |
End (write and quit) |
Programmers will be interested to know that they can enter special characters in Edlin and use these special codes.
\a |
The alarm |
\b |
backspace |
\e |
escape |
\f |
formfeed |
\t |
Horizontal TAB character |
\v |
Vertical TAB character |
\" |
Double quotation marks |
\ ' |
Single quotes |
\. |
An end |
\ \ |
The backslash |
\x XX |
A hexadecimal number |
\d NNN |
Decimal number |
\ OOO |
Octal number |
\ ^ C |
Control characters |