Live data from Hacker News

Ed is the standard text editor (2014)

wiki.c2.com

41–50 of 125 posts

Re: Ed is the standard text editor (2014)

#41

For some reason it took me years to understand the need for a line editor. It didn't make any sense in my head. Then one day I saw the famous picture of Bill and Allen as kids in front of a teletype [1] and it finally clicked. The way it worked was like this: As you keyed in your program, letter by letter, it was printed out on the paper immediately like a typewriter. If you ran the program and there was a problem, y…

That's also why TTY is the name for abstract devices. Terminals are simulated teletypes.

Re: Ed is the standard text editor (2014)

#42
post #18

There's no reason to use ed. It's a historical novelty at this point. Move on.

"oh no i reinstalled the os on my vps and now ssh has it on good authority (said authority is line 68) that someone is doing something nasty" ed .ssh/config 68d wq done, didnt fill my terminal with vim or emacs, didnt tab over to my gui editor then back again also it's a nicely "semantic"/compact/comprehensible way of expressing patches in things like portfiles or nix expressions: postPatch = '' ed Makefile etc etc s…

I always used sed for deleting lines from .ssh/config

sed -i 68d .ssh/config

It was an eye-opening experience for me when I realized sed and ed commands are almost identical

Re: Ed is the standard text editor (2014)

#43
When I started working on Sun systems back in 1991 the first terminal I used was an old model that didn't support all the cursor controls, so my only option for editing was ed. I worked that way for a year, so for a long time I was more comfortable in ed than vi. Of course on most systems nowadays ed and vi are now different modes of the same editor, as the article notes.

Re: Ed is the standard text editor (2014)

#44

I have written several scripts -- some throwaway, some not -- that use ed. If you know what you need to do to edit a file and need it automated, ed is just super handy. Here is a shell script that deletes all comments from a yaml file, then comments out a particular key: ed $file

In most cases I find `sed -i` to be more convenient than using ed in scripts, but the paradigm is a little different.

Re: Ed is the standard text editor (2014)

#46
post #4

People make fun of ed, but the command line is basically ed with the ability to execute.

That's a neat way to think of it. Coming from the other direction, for emacs users, using the command line is like using the editor since the gnu readline lib offers keyboard navigation like emacs.

Except ^W performs a completely different action. I can't count the number of times after switching from a terminal to Emacs within a couple of seconds, my muscle memory still not updated, I hit ^W only to discover I've just deleted 3/4 of the file.

Re: Ed is the standard text editor (2014)

#47
post #18

There's no reason to use ed. It's a historical novelty at this point. Move on.

"oh no i reinstalled the os on my vps and now ssh has it on good authority (said authority is line 68) that someone is doing something nasty" ed .ssh/config 68d wq done, didnt fill my terminal with vim or emacs, didnt tab over to my gui editor then back again also it's a nicely "semantic"/compact/comprehensible way of expressing patches in things like portfiles or nix expressions: postPatch = '' ed Makefile etc etc s…

> oh no i reinstalled the os on my vps and now ssh has it on good authority (said authority is line 68) that someone is doing something nasty

  ssh-keygen -R $HOST
IIRC the security warning actually used to suggest this command, but then stopped in order to discourage people from thoughtlessly bypassing it. (I don’t like this pracrice of deliberate unhelpfulness—cf Chrome’s “thisisunsafe” HSTS override—but neither do I like the results of being helpful in such cases. Ugh.)

> also it's a nicely "semantic"/compact/comprehensible way of expressing patches in things like portfiles or nix expressions

As far as I can tell, your ed script sans the wq at the end is a valid sed(1) script, and that is what people usually use for casual patching in packaging situations (although Nix also has substituteInPlace et al).

Re: Ed is the standard text editor (2014)

#48
I find ed to be the perfect program to test a new programming language. It demands good support for strings, regexes and data structures while being reasonably sized to be completed in under a week. I polished my C skills as I was learning it by writing this from scratch[1].

[1] Shameless plug, here it is: https://github.com/bojle/edd

Re: Ed is the standard text editor (2014)

#49
post #27

Perhaps it's better to see for a minute how people used this kind of editors when they first appeared, than to keep reading about them for ages: https://youtu.be/b6URa-PTqfA?t=100 (BBC from '79, mentioning how people start working from home with the aid of newfangled microcomputers and network connectivity). I'm reminded most of all of the fdisk util, where the workflow is pretty much the same: print, modify, print,…

I am sure anyone who worked with gdb without GUI/"dual" mode is aware of this experience.

https://www.seekpng.com/png/detail/350-3502039_-name-stock-p...

Re: Ed is the standard text editor (2014)

#50
post #36

Earlier quoted context omitted.

> ed .ssh/config I think this is my ed use-case as well. I've noticed I need to "apt-get install ed" sometimes. The standard editor is not always standard, it seems.

yeah, unfortunately, despite literally being specified in posix (hell, macos bundles it) one of these days i will go around pestering distro release engineers to include it; after all, it's less heavyweight than any one of their homespun lightdm greeters

The set of utilities specified in POSIX is, erm, not entirely sensible[1]. Though POSIX is more helpful than most large standards I’ve seen, it still ends up mostly having partial implementations (are there any completely 2008-compliant systems, I wonder?).

[1] http://www.landley.net/toybox/roadmap.html#susv4

Post reply on HN