4 ms·
I am curious if anyone uses ed as their editor of choice these days, assuming an actual screen and such of course. If so, why? Muscle memory? Has anyone come u
by saagarjha 6y ago
I am curious if anyone uses ed as their editor of choice these days, assuming an actual screen and such of course. If so, why? Muscle memory?
Has anyone come up with an ed with the advantages of a modern screen, so it shows the full file on the side but you can still run ed commands on it?
Edit: I should have expected getting "vi" as an answer, although I can't fault all the commenters below :P I was thinking of something a little less different, like literally just a command prompt on the bottom and a pane above centered on the line you just operated on.
- greggyb 6y ago> Has anyone come up with an ed with the advantages of a modern screen, so it shows the full file on the side but you can still run ed commands on it? It's called vi or vim.
- jolmg 6y ago> Has anyone come up with an ed with the advantages of a modern screen, so it shows the full file on the side but you can still run ed commands on it? Unless I misunderstood you, it's called Vi(m). > I am curious if anyone uses ed as their editor of choice these days, assuming an actual screen and such of course. If so, why? Muscle memory? If I'm on a machine where the choices of editor are either ed or nano, I prefer ed. Also, if I want to do some text processing on a bunch of files and it's simpler to do it with an ed script than with sed or awk, I'll use ed. It has happened. If I remember right, I wanted to edit some upper lines when some lower lines matched some regex for a bunch of files. It ended up being an ed command like 'g/foo/?bar?s/baz/qux/'. Doing something like that with sed or awk gets more complicated. > Edit: ... I was thinking of something a little less different, like literally just a command prompt on the bottom and a pane above centered on the line you just operated on. If you stick to command-mode, that's pretty much what vi and vim are. You could run this in vim: :cmap <enter> <enter>: to re-enter command-mode automatically as soon as you leave it.
- mycl 6y agoAs to your second question: Yes, Bill Joy did that in 1976 when he added a visual mode to his line editor ex that was itself based on ed. The mode was called vi (for "visual") and updated the screen as you typed ex commands preceded by a colon. All vi descendants have this feature, including Vim. :-)
- jpbpdx 6y agoed is great when you want to make a quick edit while reviewing what's above the current line in the terminal. Spot a problem, edit a file, and write a commit message while looking at the original problem, the solution, and the steps you took to get there. ed is also nice if you otherwise want to remain in the cognitive context of the stuff that's already on your terminal. Sometimes that blink that occurs when blanking and replacing your primary visual field can be useful, sometimes not. ed is a line editor. You know how lots of people like vi because it is so much easier to place the cursor where you want it? ed doesn't even have a cursor. This can be faster in some (rare) cases, but moreover it forces me to think about the file as a structure of code while visual editors generally allow me to be lazy and think about the file as an array of characters. Finally, ed is great when you know what you want to read and/or write. It is like grep but with the ability to base the next command off the previous one, or to go result by result. It is like editing in place with sed but with far less hassle/risk for one-off changes. If you'd be doing the same thing in vi, you save the trouble of typing ':'. Along those lines, ed becomes nicer for one-off edits when you compile it with PCRE support rather than the antique, POSIX-standard regular expression format. For reviewing files on the side, open up another terminal window, read a named pipe, and write to that pipe from ed. Do this with three or four different terminals and you've got a fairly complex set of indirect buffers that can be updated with a bare minimum of tooling. I wouldn't want to use only ed but I'd miss it if it went away.
- jolmg 6y ago> ed is also nice if you otherwise want to remain in the cognitive context of the stuff that's already on your terminal. Sometimes that blink that occurs when blanking and replacing your primary visual field can be useful, sometimes not. Indeed, the value of the terminal scroll-back buffer. One of the reasons I prefer CLI over TUI/GUI sometimes is that the terminal acts like a chat window with my computer. With programs like ed, you can review the conversation you've had with it.
- ansible 6y agoFor me, a lot of those use cases are covered by GNU screen. I can quickly switch between multiple terminals (which I label with names like 'edit', 'build', 'run', and 'console'). I've experimented with splitting a single window into multiple panes (GNU screen has slightly clunky support for this), but overall haven't found that to be as useful. I use the vim keys for viewing / copying the terminal window history as well as command-line history. For a long time I've eschewed using multiple tabs in Gnome Terminal, but I've started using those as well. Instead of having multiple terminal windows for different hosts, I just use different tabs, and switch between them via Ctrl-PageUp and Ctrl-PageDown. Another option there is to use another level of GNU screen with a different hotkey, but perhaps down that path lies madness.
- dllthomas 6y agoI've been meaning to try making a headless ed, that pushes commands out to the shell. It's like 30th down my list of "I should try this" at this point, though.
- rsecora 6y agoQuick automated scripted editing, in the same way you will use sed.
- xelxebar 6y ago> I am curious if anyone uses ed as their editor of choice these days, assuming an actual screen and such of course. If so, why? I use ed extensively. At least I have EDITOR=ed by default. This started mostly as an experiment to "stretch my mind," but over time ed grew on me. It changes the way you think about text editing in the same way that Haskell or Clojure or Forth change the way you think about programming. Ed isn't particularly interesting at first. It feels klunky and editing is slow. But a similar statement could be said about almost any musical instrument. It only really becomes interesting once you have interalized the mechanics of using your tool. Personally, I find myself organizing text differently than when I use vim. With the latter, I definitely want my code to be visually appealing, while with ed I want it to be appealing to edit. Definitely encourage you to give it a good, solid try if you're interested. Of note, there is a mildly famous APL programmer, Aaron Hsu, that claims to like line editors. He wrote his own actually: https://github.com/arcfide/ALE https://github.com/arcfide/ALE.
- hnlmorg 6y ago> Edit: I should have expected getting "vi" as an answer, although I can't fault all the commenters below :P I was thinking of something a little less different, like literally just a command prompt on the bottom and a pane above centered on the line you just operated on. That's pretty much what vi (or at least it's ancestors) was. Modern vim is very different to the original implementation but vi was intended to be a visual ed. Hence it's name: VIsual mode. https://en.wikipedia.org/wiki/Vi#History https://en.wikipedia.org/wiki/Vi#History