ed(1) mastery is a must for a real Unix person
bsdly.blogspot.com
bsdly.blogspot.com
I thought this was like nerd supremacy but it does ring true: your text editor doesn't matter, you are not a better writer / programmer / person because of what editor you use.
I did thoroughly enjoy the dig about BSD supremacy. Those guys are worse than vegans and environmentalists. :)
The "everything is a printer" abstraction started because PDP's that ran V7 Unix at Bell Labs really did use Teletypes for user interaction.
Ditto textareas in Chrome and Firefox.
somebody uses Emacs...
But seriously, the tribalism over which is better is ridiculous, but a good writer/programmer/person chooses their tools intentionally, and makes their tools work for them instead of against them. My choice of editor doesn't make me better than you, but it makes me better than a version of me using sub par tools that I have to fight to make work. It's about reaching flow state and being able to do work, and make work happen. If forced to cut down a tree in 5 minutes, the learned lumberjack will spend 3 sharpening their axe.
The commands in vi are based around the commands in ed. They belong to the same family. sed is also a family-member, and an amazing tool. But I won't be sorry if I never run into ed again. Essentially, it's a rudimentary editor with zero dependencies; it doesn't need a curses library, in particular. And it would work on a terminal with only a printer for output, which was useful, back then.
I can still get by using ed when I have to though.
Still blows my mind that projects like notepad++ have been around for the literal lifetime of younger users and somehow MS just did not give any sort of shit about their terrible editor.
They do superficially similar jobs, but the similarities end the first time you try to use one for a job that requires the other.
A user who has an grade F and many grade A and B options may not be better off if upgraded to a default D or C. In fact if they don't move on to one of the A options they may be worse off.
Maybe now, I'm told it has been improved in windows 11. But for decades, it was the only "mainstream" text editor I'm aware of that didn't have multi-level undo/redo (that is, it remembers your last action, and that's it). The fact that it stuck around this long without that feature is amazing, really.
It's use is really limited to modifying ini/properties files, unless you really hate yourself (and many of us did in the 2000s with our "made in notepad" website banners)
There is a bug in the article: i" vi(1) does offer a distinctly visual interface that only became possible with the advent of the video terminal, affectionately known as the glass teletype."
The term "glass teletype" was coined specifically once there were terminals with addressable displays (that is, your program could place a character at any character position on the display at location X,Y). Until then displays drew at the bottom of the screen and scrolled the entire display upwards when receiving a line feed. Basically like a teletype!
The blog author has a white beard so could potentially be old enough to remember those days, but also is in Norway so the slang could have been shorn of its roots in the process of crossing the Atlantic.
I've also had to configure equipment that only provided a serial port. Some let me configure TERM, but others did not. Either way I knew ed and so figuring out how to configure TERM wasn't worth the bother for quick changes.
Even in the late 1990s, computers were sometimes slow enough that for quick changes I could open ed and make the change faster than vi could load. Don't get me started on loading emacs on those (which most people did and probably why ed was faster)
However, having a basic idea of "sed" is a goldmine for super-quick command line pipeline kinds of tricks. Even in this day and age.
I mean we’re all joking in this thread to some extent, but actually, I don’t know that I don’t believe this.
A joke I used to tell people is "don't know how to quit vi? Just type Q to enter Ex mode, then you can exit vi just like how you would exit ed."
Why? Because we have a new friend in the house who effectively has to interact with the outside world via teletype terminal.
The LLMs!
As to why I run "ed" instead of "vi": if I get just a few errors from some script I just copied over, I could run "ed" and the error message is still on the screen (because ed doesn't repaint the whole screen). I would run vi and screen if I expect to fix more than just a few lines.
Many times I'd have to fix a server with a configuration issue causing /usr to not mount correctly on boot. When you're at a single-user shell and no /usr/bin/vi is available suddenly knowing the basics of /bin/ed becomes very useful.
Of course these days most UNIXes moved away from a separate /usr partition so if the root filesystem mounts you have a full-featured vim.
In the context of a shell script, there are things you can do with ed and a here document that are extremely difficult to do any other way. For example, I had to recover my website from the wayback machine during covid lockdown (long story).
I decided to change everything to markdown and wanted to add yaml frontmatter to every one of a hundred or so markdown files. The Yaml frontmatter needed to be different for each file and I ended up having to make various tweaks before I brought it back live.
So, ... multiple times I had to do edits like "in the fourth line above the -- that ends the yaml front matter, change x to y". This is a very tough edit to make with the usual suspects (sed/perl/awk etc), but is a breeze to do if you run ed in your shell script and have the commands you want to run supplied by a here doc.
I use sed for non-interactve editing as well. Below is a favourite of script of mine ("ins") that I use frequently for non-interactively inserting text at the top or at any line in text files.
#!/bin/sh
case $# in :)
;;0) exec echo usage: ${0##*/} target \[line-no\]
;;[12]) sed -i -e ${2-1}r/dev/stdin -e1N $1
esac
Stupid examples: echo 93.184.216.34 example.com|ins /etc/hosts
cat 84*.c|ins 084.l 151 # insert some .c files at line 151TEXT EDITOR.
Make no mistake, there are plenty of people in our industry who hold genuine opinions like this and are more than happy to bash less experienced people for trivial tool choices.
No, it's not. It really doesn't matter at all what editor you use. And there are so many to choose from. You don't even need to stick to only one editor. I sure as hell don't.
Editor loyalty is tribalism, and tribalism is myopic. Use whatever tool gets the damn job done, and learn a few of them so that you at least know what's possible.
However be careful. Editors do offer different features. Some things really are easier/better in a different editor, thus even after you settled on an editor you should - every few years - take a look around to see if maybe something else is enough better in some way as to be worth learning in depth. While sometimes it seems like the wrong choice will get the other tribe to kill you (or condemn you to hell for eternity), I'm not aware of that ever happening - generally you can remain friends with other people after switching.
It's fine to use Vscode, but it's nice to know emacs/vim/nano, it's very nice to know ed/vi, but it's really nice to not have to use echo.
But seriously, you fell for an April Fools' joke.
I've never actually used ed once in the last 30 years of using Unixes both on a programming and admin perspective.
Edit: ok he got me :)
We have come so far since.