Linux 3 min read

Ed: The Standard Text Editor (A Survival Guide)

Suresh Suresh
Ed: The Standard Text Editor (A Survival Guide)

In the vast world of Linux text editors, there is one editor that predates them all. Before Vim, before Emacs, and before Nano, there was Ed.

Created by Ken Thompson in 1969 for the original Unix operating system, Ed is known as the “Standard Text Editor.” It was built in an era when monitors and screens did not exist, and programmers interacted with computers using teleprinters that literally printed output onto rolls of paper.

Today, launching Ed feels like walking into a dark room without a flashlight. It provides zero visual feedback. There is no menu, no cursor to move around, and no text visible on the screen until you explicitly ask for it.

So why learn Ed today? Because understanding Ed is the key to understanding sed, grep, and the very foundations of Unix regular expressions. This is your survival guide.

The Absolute Minimalism of Ed

When you launch Ed, you are greeted with… nothing.

$ ed my_file.txt
34

That number (34) is Ed telling you how many bytes are in the file. It won’t show you the text. If you type a command it doesn’t understand, it responds with a single question mark: ?. That is the entirety of its error reporting.

Understanding Line Editing

Ed is a Line Editor. Because it was designed for paper printers, you cannot use arrow keys to move a cursor. Instead, you issue commands that target specific lines by their line number.

Every Ed command follows a basic structure: [address] [command].

Viewing Text

To see what is in your file, you must tell Ed to print it using the p (print) command.

  • 1p : Prints line 1.
  • 1,5p : Prints lines 1 through 5.
  • ,p : Prints the entire file.
  • n : Prints the current line with its line number attached.

Adding Text

To write text, you must enter “Input Mode” using the a (append) or i (insert) command.

  1. Type a and hit Enter to start appending text after the current line.
  2. Type whatever text you want.
  3. To exit input mode, type a single period . on its own line and hit Enter.

Deleting and Changing Text

  • 3d : Deletes line 3.
  • 2,4d : Deletes lines 2 through 4.
  • 3c : Changes line 3 (deletes it and drops you into Input Mode to replace it).

The Power of Regular Expressions

Ed’s greatest legacy is its search capabilities. In fact, the famous Unix tool grep gets its name from Ed’s global search command: g/re/p (Global / Regular Expression / Print).

Searching

To find a word in your file, type a forward slash followed by the word:

  • /apple : Jumps to the next line containing “apple” and prints it.

Substituting (Find and Replace)

Ed uses the exact same substitution syntax that modern tools like sed and Vim still use today.

To replace the word “apple” with “orange” on the current line:

s/apple/orange/

To replace it globally across the entire file:

,s/apple/orange/g

Saving and Quitting

If you are trapped in Ed, do not panic. (Ctrl+C will not save you!)

  1. Ensure you are out of Input Mode by typing a single period . and pressing Enter.
  2. Type w and press Enter to Write (Save) the file. It will output the new byte count.
  3. Type q and press Enter to Quit.

If you want to force quit and destroy any unsaved changes, type Q (capital Q).

Conclusion

Nobody uses Ed as their daily driver for writing code in 2026. However, it is an incredible educational tool.

By learning Ed, you instantly unlock the ability to write advanced sed scripts, you master the core command-line mode of Vim, and you gain a deep appreciation for the history of Unix. Plus, the next time someone challenges you to edit a file on a severely broken terminal without a visual interface, you will know exactly what to do.

Suresh

Written by Suresh

A passionate technology enthusiast, blogger, and self-taught developer. I write about Linux, Open Source, Cloud Computing, and emerging technologies to help students and beginners learn tech for free.

Discussion

Loading comments...