1. 12
    1. 5

      It is still useful in shell scripting though, given it can edit a file in-place.

      1. 3

        I only recently discovered the use of ed or ex in scripting and it has been a life saver. I was trying to do complex edits with sed and awk, which was hard enough even before you consider portability. The common answer seemed to be Perl, but I wasn’t really happy with that either.

    2. 4

      I actually had to laugh when I saw this title. Was ed ever a “good” editor?

      1. 16

        Yes, absolutely. Ed was a good editor in the 1970s, when 300 baud links were reasonably fast things and teletypes with printed output were common, and even significantly into the 1980s, when you might still be dealing with 300 baud serial links (1200 baud if you were lucky), heavily overloaded systems, very dumb CRT-based terminals, or some combination of all three. About its only significant limitation in those situations is that it’s a single file at a time editor, which makes some things more awkward. Using any visual editor in those situations is a frustrating exercise in patience (or outright impossible on hardcopy teletypes or sufficiently dumb terminals).

        (I’m the author of the linked-to article.)

        1. 2

          The ancestors of ed, such as CTSS QED and it’s descendants on Multics (QEDX, Ted) all worked on multiple buffers, but those (and other) features were not carried forward to the simpler UNIX ed.

          1. 1

            Given that Ken Thompson was fully familiar with QED et al (cf), the omission of multiple buffer support in ed is clearly deliberate. I wonder if Thompson felt forced to do it by resource constraints on Unix or if he just decided that it wasn’t important enough and omitting it simplified the experience in ways he wanted.

            (By the time of V7 I suspect that resource constraints weren’t a big enough issue, and the Bell Labs people certainly were willing to rewrite programs if they should be improved. And I believe that people did versions of QED for early Unix, too.)

        2. 1

          I don’t think I’ve ever actually used ed. I grew up in the 90s, so by then it was pico/nano. Is edlin from the MS-DOS days similar? If so I did use edline quite a bit, but would not be able to tell you anything about how to use it today.

          1. 2

            I never used edlin, but I’d guess that editor has more in common with CP/M ED than UNIX ed.

          2. 2

            Based on the edlin Wikipedia page, edlin is kind of a relatively simplified take on ed (although that’s not necessarily its historical origins). Full ed is fairly powerful, with a lot of text manipulation commands that don’t require you to retype lines to modify them and a bunch of ways of specifying what lines you want to operate on (including ‘lines that match this regular expression’). Interested parties can see the GNU ed manual. It’s probably simplest to start with the commands list if you want to see what ed is capable of.

            (GNU ed is a moderate superset of V7 ed in both commands and its regular expression support.)

      2. [Comment removed by author]

      3. 1

        I’d have to say no - it was clearly inferior to the QED descendants QEDX (and it’s descendent, Ted), which preceded it.

        In defense of ‘ed’, this simplification was a design decision, according to Ritchie.

        When using Multics, I often find myself reaching for QEDX, especially for quick editing tasks.

    3. 4

      I occasionally use ed when I need to delete a specific line of a file by number. Most commonly, I suppose, when I need to clear out a specific entry in ~/.ssh/known_hosts.

      The other time I reach for it, on occasion, is when I want the paper teletype-like property it provides; i.e., if I need to make a small edit in a file and I want that to appear in my scrollback for whatever reason. It’s hard to have a specific sequence of edits appear in your terminal history with a visual editor.

      I recognise that I’m somewhat on the fringe, though.

      1. 4

        ssh-keygen -R host is probably the better tool to use than ed for that.

    4. 4

      I don’t know if I’m getting a wrong impression whenever I see people unironically advocating to use Ed, I always feel like it’s some kind of esotericism and wanting to show of how “pure” one is in a Unix sense. The first time it really struck me was when someone posted a thread on Lobsters telling everyone how he was using Ed in public and he doesn’t need more than that. My sense is that this phenomenon is rather common, and that people to this day “like” (?) imagining that they are still working on Teletype systems without an Internet connection.

      And I’m saying this as someone who has actually had a real use from Ed (editing files over slow collections, batch editing).

      1. 1

        The author of that post was far from mainstream, I believe.

        I’ve been a Un*x user since the early 90s (student, then enthusiastic Linux and BSD user, now way older and pragmatic) and the very first editor I was exposed to was Emacs (on a Sun “dickless” workstation with a monochrome screen and 1st gen optical mouse).

        Sure, this was an educational environment and Emacs was probably considered more “user-friendly” than vi, but we still had to memorize keystrokes - there was no GUI to speak of (menus and buttons etc). Even now I’m comfortable using emacs -nw in a 80x24 terminal window… even though I have a working knowledge of vi for slower systems.

        The first time I heard of ed was in conjunction with the Gnu joke that I’ve now posted twice on Lobsters (in this thread, and the linked one).

    5. 4

      The version of Ed source I saw years ago had a single comment /*. Editor */

    6. 3

      Quote from a relevant article about vim, since it is a descendent of ed:

      Coulouris had brought along a Dectape with the code for a text editor of his own, a modification of ed which he’d named “em” — a shortened version of “ed for mortals.”

      “I christened it that after Ken Thompson visited our lab at QMC while I was developing it and said something like: ‘yeah, I’ve seen editors like that, but I don’t feel a need for them, I don’t want to see the state of the file when I’m editing’.”

      The fact that programmers knew and attempted to improve from the amount of mental state required 30+ years ago seems like the article is a relevant reminder to the number of people who aren’t Ken Thompson (which has dramatically increased since then).

      PS I think Ken uses Acme or Sam now, so even he moved on to the world of visual editors.