ed is a powerful text editor based on non-visual (line-oriented) behavior, originally written by KenThompson
for the early UnixOperatingSystem
. Think of it as an ultimate form of non-WYSIWYG: instead of seeing some part of the text you're editing on the screen and making modifications into the seen version, you have separate commands for showing text, adding it, moving in it, changing it, and so on. The standard argument about vi, that you have to learn it anyway if you're going to rescue a Unix system sometime, applies double to ed: I remember some rescue disk with only ed, no vi. (Much in line with echo *
as an ls
replacement). As with vi, after some usage you might become quite fluent with ed.
There are also some environments where the line-oriented paradigm is the only option. These include environments where output of different programs continuously clutters your screen (MultiUserDungeons?
, for example), terminals that have no positioning commands, and very slow lines (you don't want ncurses to refresh your screen on a 2400 baud connection every time you add a line, even if curses uses differential display).
These environments were once the norm for interactive computing. The original UserInterface to the UnixOperatingSystem was the actual ASR-33 TeleType, literally printing the user output line by line onto a roll of paper. Completely line-oriented and very slow. Other TimeSharing? OperatingSystems of the time, such as MulticsOs, had basically, or indeed exactly, the same UI hardware. Many of the early character-based video terminals didn't have the speed or the intelligence to do much better. But compared to entering your FortranLanguage program on a stack of HollerithPunchCards...
So "full-screen" character-based programs in the mould of (n)curses, NetHack and ViEditor (the "VIsual Editor") were impossible in the early Unix environment. This is one of the reasons why the classic Unix CommandLineInterface is indeed completely line-oriented. So the joke that "ed is the standard editor" is a HaHaOnlySerious reminder that even vi is a concession to GraphicalUserInterfaces, a deviation from the pure, uncompromising Unix way. ed was indeed the standard editor on early Unix, and most of the early Unix source code was written with it.
Incidentally, "visual" character-oriented interfaces are more fully integrated into the world of PlanNineFromBellLabs, BellLabs's intended successor to Unix. SamEditor? is the low-end standard editor on Plan 9: it has a visual interface and even mouse input. sam is now KenThompson's regular editor. Sell-out! :)
(Sources: mainly http://catb.org/esr/writings/taoup/html/ch13s02.html and http://catb.org/esr/writings/taoup/html/ch02s01.html#genesis (spot the teletypes!) from TheArtOfUnixProgramming.)
In addition to being one of the only line-oriented editors (ex notwithstanding), ed is one of the least friendly editors around. It does nothing without being asked to, its error messages are mostly '?', it does not offer help in any form, and it is not customisable. It is a modal editor, sometimes leaving you more lost than vi. However, I think it is easier to get out of ed than of vi if you got there by accident. (And you do get into vi by accident a lot.)
I think an enhanced ed, with some niceties like automatically showing the context of editing, could easily be my editor of choice. Also, I think the model of changing text should be rethought.
Here are some advice to get you going:
- To edit a file, type "ed <filename>"
- End all commands with an <enter>
- To view the contents, type ",p"
- To view a few lines around your current location, type "--,++p"
- To go to the next line, type "+" (or simply press Enter without typing anything)
- To go to the previous line, type "-"
- To insert text, type "a". Give the text to be inserted. End with a "." (dot) alone on a line.
- To append something to the end of file, use "$a".
- To edit text on a line, type "s/oldtext/newtext/"
- If you get lost, type a "." (dot). If inserting, it will take you into command mode; if in command mode, it shows the current line.
- ed reports errors by "?". Type "h" to get an error message (does not work with all vi's).
- To delete a line, type "d".
- To search for some text, type "/text/".
- When done editing, give the command "w", then "q".
[the following part moved from EmacsVsVi
From: email@example.com (Patrick J. LoPresti?)
Sender: firstname.lastname@example.org (News system)
Subject: The True Path (long)
Date: 11 Jul 91 03:17:31 GMT
Organization: Massachusetts Institute of Technology
Xref: ai-lab alt.religion.emacs:244 alt.slack:1935
When I log into my Xenix system with my 110 baud teletype, both vi
*and* Emacs are just too damn slow. They print useless messages like,
'C-h for help' and '"foo" File is read only'. So I use the editor
that doesn't waste my VALUABLE time.
Ed, man! !man ed
ED(1) UNIX Programmer's Manual ED(1)
ed - text editor
ed [ - ] [ -x ] [ name ]
Ed is the standard text editor.
Computer Scientists love ed, not just because it comes first
alphabetically, but because it's the standard. Everyone else loves ed
because it's ED!
"Ed is the standard text editor."
And ed doesn't waste space on my Timex Sinclair. Just look:
-rwxr-xr-x 1 root 24 Oct 29 1929 /bin/ed
-rwxr-xr-t 4 root 1310720 Jan 1 1970 /usr/ucb/vi
-rwxr-xr-x 1 root 5.89824e37 Oct 22 1990 /usr/bin/emacs
Of course, on the system *I* administrate, vi is symlinked to ed.
Emacs has been replaced by a shell script which 1) Generates a syslog
message at level LOG_EMERG; 2) reduces the user's disk quota by 100K;
and 3) RUNS ED!!!!!!
"Ed is the standard text editor."
Let's look at a typical novice's session with the mighty ed:
eat flaming death
Note the consistent user interface and error reportage. Ed is
generous enough to flag errors, yet prudent enough not to overwhelm
the novice with verbosity.
"Ed is the standard text editor."
Ed, the greatest WYGIWYG editor of all.
ED IS THE TRUE PATH TO NIRVANA! ED HAS BEEN THE CHOICE OF EDUCATED
AND IGNORANT ALIKE FOR CENTURIES! ED WILL NOT CORRUPT YOUR PRECIOUS
BODILY FLUIDS!! ED IS THE STANDARD TEXT EDITOR! ED MAKES THE SUN
SHINE AND THE BIRDS SING AND THE GRASS GREEN!!
When I use an editor, I don't want eight extra KILOBYTES of worthless
help screens and cursor positioning code! I just want an EDitor!!
Not a "viitor". Not a "emacsitor". Those aren't even WORDS!!!! ED!
ED! ED IS THE STANDARD!!!
When IBM, in its ever-present omnipotence, needed to base their
"edlin" on a UNIX standard, did they mimic vi? No. Emacs? Surely
you jest. They chose the most karmic editor of all. The standard.
Ed is for those who can *remember* what they are working on. If you
are an idiot, you should use Emacs. If you are an Emacs, you should
not be vi. If you use ED, you are on THE PATH TO REDEMPTION. THE
SO-CALLED "VISUAL" EDITORS HAVE BEEN PLACED HERE BY ED TO TEMPT THE
FAITHLESS. DO NOT GIVE IN!!! THE MIGHTY ED HAS SPOKEN!!!
The best thing about ed is it has this really useful visual mode. Just start it up and type :vi ... but don't try that on your 110 baud tty.
That should not work. Maybe you are on an evil system where ed is a link to ex?
- The enhanced version of ed connected to vi is named ex. The original ex was a fork of ed, but the two were never identical, although some systems threw away ed and made it a link to ex, confusing things from the user perspective.
- The original vi carefully optimized output to suit transmission speed, so that it was in fact usable at 300 baud and even at 110 baud on a display -- it was of course painfully slow, but everything was at 110 baud. On a printing device like a teletype, vi shifted to open mode, which made it actually quite usable. That was the smart choice most of the time on displays at 110/300 baud, too, but it was sometimes nice to shift between open mode and full (actually partial) screen mode to see surrounding context. Naturally one would also drop into plain ex mode frequently, too, to completely minimize I/O traffic.
Hmm. Actually I'd really like a 110 baud tty - anyone know where I can get one these days?''
Get a VT100 and set it to 110 baud.
- They're collectibles. Due to weight and therefore shipping cost, I don't think Ebay is the most popular place to sell them. Try vintage computer groups of various sorts.
- The XScreenSaver project has a few programs (phosphor, apple2) that let you simulate a laggy screen refresh. See the thread on the Arch Linux board: https://bbs.archlinux.org/viewtopic.php?pid=707274
- If you have access to a Mac, try GLTerminal. The configuration system (command-comma) is kind of glitchy but you should be able to empirically discover and work around the bugs. Set it to 110 baud (or 50 baud, if you feel truly masochistic) and enable the "Classic" renderer mode. Then put it in full screen mode (command-return) and pretend that Apple is manufacturing VT100 laptops.
I was reminded of the famous "ed
is the standard text editor"
rant above when I saw on a colleague's desk a box bearing (among
others) these words:
- Once you've experienced the massive power and time saving advantages of working with the one single editor (no matter what your editing or programming task) you'll wonder how you ever got by without ED! Every programmer, system administrator and PC User could do with some help from ED!
- Imagine the benefits of using the one editor for all your programming languages. From Assembler to VHDL, ED is the one-stop productivity tool that slashes coding time. [...] ED powers up YOUR development environment, without tying you to a particular language or platform.
ED appears to be a hairy thing with lots of windows, syntax colo[u]ring, and the like...
Mmm, now there's an idea: adding syntax coloring to ed...
Perhaps we could also build a Lisp interpreter into it?
I am reminded of a published standard for a baby formula, and the Q&A generated when various mothers inquired if they could substitute honey for corn syrup, add vitamins, use skim milk rather than whole milk, and so on. The originator of this formula spent some effort explaining that the formula worked as it did because of the way it was formulated, and that messing with the ingredients would alter that formula. He concluded with this bit of pith: "You would also not add motor oil."
However, in keeping with the theme and spirit of "small and terse" I suppose I could let you add ... a Forth interpreter.
Like the ForthLanguage
interpreter in the CanonCat
says: ¡El Ed es el editor de textos estándar!
Ed editor textorum probatissimus est -- Cicero, De officiis
Do people actually use ed anymore? On most computers, either ed is gone altogether, or it is a symbolic link to vi. -- Zydia, http://www.theatons.com/
Well, on my box, it is still a glorious stand-alone executable. Not that I use it ever... -- StephanHouben
I occasionally use it, when I am operating over intercontinental distances on a fairly slow link. Just like having a 32-bit colour, 21", 1600x1200 VT100 :)
By the by, ViEditor
started its life as a visual mode for ed. If you don't have vim or some such installed, your link of ed to vi is in all probability a link of vi to ed; it will start up automagically in visual mode if envoked by that name.
At least on the free UnixLike
s I've seen, ed and vi are separate programs. ed's size on my debian box is around 42k.
I thought ex (not ed) was the non-visual variant of vi. It is common for vi to be a symbolic link to ex or vice-versa.
The GNU system contains a stand-alone ed, so Linux systems which are
really GNU/Linux systems (another HolyWar
) typically have a
stand-alone ed. See http://www.gnu.org/directory/ed.html
for GNU ed.
The original vi was based on ex, which was an upgraded ed. Linking ed to ex wasn't uncommon, but it was never standard; ed and ex were different programs, and if some local installation didn't futz with things, there was always a separate standalone ed. On the other hand, ex and vi were not separate programs, they were two modes of the same program. It would look at its invocation name to determine whether to begin in ex-mode or vi-mode.
One can't be sure of any of the above in this age of ed-rewrites and vi-clones; it all depends on which clone and what that author felt like doing.
For instance, I cannot force vim to start in ex mode without it doing a vi-style screen-clear/init sequence, which screws up various open-mode tricks I used to do with the original real ex.
Note that Mac OS X has a standalone ed
(and a real one too), but it seems a bit bloated (weights 111K)
- It's a universal binary. It has PowerPC and Intel code in the same executable. Near as I can figure, the PowerPC part is 55K, and the Intel part is 51K.
I normally use ed
when configuring a new platform, just long enough to get sam
working on it. ed
is also useful for quick edits where you know exactly what you need to change, e.g. /Daisy/s//Dooley/ w q -- DAGwyn
Ed is the standard editor in Plan9. (Apart from acme and sam)...
- "apart from": in other words, it's not the standard editor.
I was just wondering ...
I came into the game late, and through a side door, so my first ED
was the ED that shipped with CP/M
rather than Unix.
One of the things I came to like about it was that you could address every single character
in a text file, including the separate CR and LF characters. You could deliberately remove all occurences of either one. You could insert a second CR before every LF. Control was very granular, and made CP/M ED a character
editor, rather than a line
I actually wrote programs, manuals, and articles with this editor. During "the retail years" when I helped sell CP/M machines, I actually encouraged my customers to learn ED and become productive with it before buying any word processing software
so that they would have a better understanding of what other software was doing with text.
Since the demise of CP/M, I've not been able to find a DOS (or *nix) implementation of ED that worked the same (sniff). I would be pleased indeed if someone knew where I could obtain a true CP/M ED clone.
you're talking about is essentially unrelated to the Unix ed
, which was inherently line-oriented, and could not be turned into a character editor of the sort you describe. I don't remember any kind of "ed" under CP/M, but no doubt my memory has just faded (like someone else mentioned, I did use Wordstar a lot)]
It's not quote the same as CP/M ed, but TECO (TecoEditor) is a command line driven editor with character addressing.
- TECO cannot possibly have anything to do with anything on this page other than the fact that, yes, it was a character editor, so that comment seems a complete irrelevency. (Long ago I was fluent in TECO, and it was amazingly powerful, although TECO command scripts looked like line noise.)
I used ElectricPencil?
on CP/M rather than ED. Interesting to hear your impressions.
- I only used ElectricPencil? once, and didn't have time to get good with it. WordStar I used for years. Wrote everything (programs, manuals, articles, stories, resumes, blah-blah-blah) with it for those years. It was during that time that I "discovered" CP/M's ED and took the time to master it. It was refreshing. I already had a several-year background in telex/teletype, so the "electronicized paper tape" was quite comfortable. I even hijacked the idea into my comms program (SoftWire?) and added a character-and-line editor mode to the existing full-screen editor. I had modeled the full-screen editor on WordStar (with the same basic controls), and I modeled the later editor on ED. It was this experience that made me appreciate the value of low-level understanding, even in a high-level application. From this came the advice to customers: "learn ED first, then choose a word processor." -- gh
Interesting idea: low-level understanding helps you when you use a high-level application. Is this a form of the TelescopeRule
? Or is this concept different enough that it needs its own WikiName
? (Some people on FreshmansFirstLanguage
seem to be arguing over whether this low-level understanding really
helps, or whether it's a waste of time that would be better spent practicing with the high-level tool).
If you're looking for a quick and dirty and small editor dig out your old floppy disks from stacker, they contained a real nice little editor called ED. I still use it with win 8.1 sunwukong.