Follow

anyone use a line editor on here? can you describe the usage? making one of my own as a PoC

· · Web · 4 · 1 · 0

@meeper ya. whats the common stuff you do, how do you do it

@eris

It's more or less like the vim command line :s/fd/sdjf

but the very basic concept of the editor

you can work on ranges or on a particular line by picking it and basically run what amounts to sed on it

so you can pick line 3 and change it's text entirely or append text or use say the s command to subsitute a particular block

you can also work on ranges of lines
@eris you run say ed and you get a ? (or sometimes nothing, or sometimes a ? if your command can't be interpreted) and have to enter any command or directive

@meeper gnu n busybox ed dont do that anymore lol

@meeper hmm.. guess my distro enabled good errors by default

@eris You mean something like th̶̶̶̶̶e̶̶ ̶̶s̶̶t̶̶a̶̶n̶̶d̶̶a̶̶r̶̶d̶̶ ̶̶U̶̶n̶̶i̶̶x̶̶ ̶̶e̶̶d̶̶i̶̶t̶̶o̶̶r̶ ed?

accessibility tip 

@friend that will not be very friendly to screen readers, they won't know where word boundaries are and that they should ignore all those hyphens

accessibility tip 

@csepp Hmm, someone on here once said that their screen reader actually handles these Unicode diacritical marks perfectly fine.

And it makes sense to me that screen readers would handle them, since there's tons of diacritical marks. Without synthesized pronunciation for e.g. "Tiếng Việt" (Vietnamese), discarding the diacritical marks is probably better than mentioning every single one.

So, yeah, I've been allowing myself to use them until I find opposing evidence...

accessibility tip 

@csepp I do absolutely hate, though, how we're having to talk about this on a purely hypothetical basis. It's not like you need a visual impairment to be able to hear a screen reader.

But at the same time, you kind of do. Because shit's expensive/proprietary and probably not that easy to set up either.
For anything more complex like website structure, you need to learn how to interpret the output, too.

@eris I used ed for a long time and I basically just used the s command and nothing else except for i and n. but I don’t think that’s how normal people would use it I just couldn’t memorize the others

@eris Do you want to know how line editors work, or do you want to know the most important features from a user's perspective?

@eris I'll talk about how I use "ed".

When programming, I rarely type a new line from scratch, instead I copy an old line with "t" and then modify it by regex replacement "s". This means I never have to manually count leading spaces.

If you want fewest possible commands, make copy "t" and delete "d", and don't bother with move line "m", it is rare.

Search "/" is SO important for navigating. Don't expect people to memorize line numbers, which will be changing constantly. I search for landmarks, like section headings that I know live in a particular place.

Avoid absolute line numbers. Anyplace that supports an absolute line number (like 1234) should also support a relative line number based on current position (like -5 or +5) and a search based on current position (like /foo/ or ?bar?)

For writing prose, I don't wrap to 80 columns because it's such a pain to re-wrap it when making edits. So the max line length should be unconstrained.

Does this help?

@devinprater I don't use ed as a primary editor. It is usually not the right tool. That said, it leads to a different way of thinking, which can be useful sometimes.

When I prepare pull requests in ed, I am always thinking about how to make my change as small as possible, because typing and editing has a real cost. It is the opposite of vi, where making massive bulk changes is super fun so I edit more than I should.

@devinprater Yes, I have heard of edbrowse. What a hidden gem. It has the best Javascript support I've ever seen in a CLI browser.

@psf I guess I just have to use it more. Line editing is just, so different than anything I've ever used before, even VIM.

@devinprater If you are already comfortable with Vim, try dropping into ex-mode with "Q". This puts the editor into a line-oriented mode where you can quickly enter a lot of Ex commands. Which is just another name for the colon-prefixed commands that you are probably already familiar with, like :w and :q.

This lets you use Vim as a strangely powerful line editor that just happens to allow switching back to screen mode if needed.

The Ex command is very nearly a straight superset of Ed. This is how I learned Ed.

@psf also, hiw would i say.. delete the next five lines? (and the 5th line from here

@eris Okay, so in ed, each editing command takes a range prefix. Here is an example.

d = delete the current line

10,15d = delete line 10 through 15

-5,+5d = delete five lines before current and five lines after current

?foo?,/bar/d = delete backwards to the line containing foo, and forwards to the line containing bar

Does this make sense? This is the only reason ed is usable with large editing tasks... otherwise you'd be stuck doing everything one-line-at-a-time, which is very laborious.

There's also the g command, which works like this:

g/re/command

g is a special command that collects all the lines matching /regular expression/, and lets you run a command on all of them.

"d" is the delete command, so g/re/d would delete all lines containing re.

"p" is the print command, so g/re/p will print all lines matching re. Which incidentally is how the unix grep command got its name.

@psf coolcool. probably not gonna implement ed exactly

@eris Please do share what you come up with!

Sign in to participate in the conversation
Merveilles

Revel in the marvels of the universe. We are a collective of forward-thinking individuals who strive to better ourselves and our surroundings through constant creation. We express ourselves through music, art, games, and writing. We also put great value in play. A warm welcome to any like-minded people who feel these ideals resonate with them.