Live data from Hacker News

Use Vim Inside a Unix Pipe Like Sed or AWK

blog.robertelder.org

41–49 of 49 posts

Re: Use Vim Inside a Unix Pipe Like Sed or AWK

#41
post #18

Vim is actually a relatively bad filter (some reasons are mentioned in the caveats section of the article). I explicitly designed my vis editor[1] in such a way that it can be used as an interactive filter. The following works as expected, use :wq to write to stdout: printf "foo\nbar\nbaz\n" | vis - | sort dvtm uses this mechanism to implement its copy mode. I also recently integrated sam's structural regular express…

Thanks for your efforts with the Vis editor... You can do this with any other editor using "vipe" from "moreutils" package. It just opens $EDITOR with stdin input (put to a tempfile) and then reads the tempfile and dumps it in stdout. printf "foo\nbar\nbaz\n" | vipe - | sort # invokes $EDITOR

Yes vipe is indeed useful for editors which do not support it by themselves. Personally I find a solution solely based on pipes without temporary files more elegant.

I should probably let dvtm fall back to vipe if it is installed. Also I will have to check whether there is an easy fix to make vipe+vis work.

Re: Use Vim Inside a Unix Pipe Like Sed or AWK

#42

Earlier quoted context omitted.

I find learning this lesson often enough made me realize that it's difficult to remember that people in the past were every bit as intelligent as people are now. They simply had fewer, older tools. There's another related lesson there that progress, like evolution, is progress in a certain direction. No one said that direction is whatever you call "good" at the moment.

> people in the past were every bit as intelligent as people are now. ... and some evidence supports they were smarter... http://www.huffingtonpost.com/2013/05/22/people-getting-dumb...

Good point.This argument that domestication lowers intelligence (among other powerful abilities) and that we are unquestionably domesticating ourselves is pretty damn solid. The only argument against it seems to be "... but my ego!".

Obviously there is some interplay with the fact that we develop new mental models and thinking tools to augment intelligence.

Also immersion as children in highly abstract ways of thinking further augments/multiplies raw intelligence (most convincing explanation to the Flynn effect imo).

I've lost the link, but there was an excellent article I read related to the amazing Otzi discovery (https://en.wikipedia.org/wiki/%C3%96tzi) describing how adults of that era (modern humans, primitive societies) would likely have been terrifying to us now in just how much they outclassed us in raw strength, intelligence and stamina. We would be relying a lot on the benefits of childhood nutrition and education to feel superior. This isn't completely convincing, there are a lot of factors in play, but those levels of brutal competition and danger would have a profound effect, especially epigenetically.

Re: Use Vim Inside a Unix Pipe Like Sed or AWK

#43
post #10

This post hints toward vim's history: the ed family of editors. http://blog.sanctum.geek.nz/actually-using-ed/ http://blog.sanctum.geek.nz/using-more-of-ex/ A big use case for them was using them as scriptable editors in pipelines, and a lot of vim's commands are inherited from them. The diff(1) utility actually has an option to emit ed script, allowing files to be patched in ed pipelines: http://www.gnu.org/software…

It's common for people today to think of ancient Greeks as being very unsophisticated and primitive, but then when you start to read what ancient philosophers wrote you think "Wow, these guys really had things figured out, maybe better than we do now." I kind of feel the same way comparing modern GUI applications to ancient editors like ed.

But then you remember that Ed was designed to be used on what essentially was a typewriter, because dialup was so slow, that you couldn't send an entire screen worth of text at once. So you would basically be remembering the text in your head, while inserting and regexing lines.

And the great error handling when it doesn't know what you just told it to do. ?

Re: Use Vim Inside a Unix Pipe Like Sed or AWK

#44

Hi, I'm the author. While I've got your attention, I would be interested in hearing feedback about how I can improve the reading experience (text colour/fonts/sizes/wording etc.) of my blog posts. I used to have blinking text for the email signups at the bottom, but I got rid of it since it didn't have a huge effect (I think it only doubled the conversion rate). I have learned that some people really hate blinking te…

Actually, pretty good, though I'd recommend letting body font being solid black or perhaps #330 (and no lighter).

I can't view elements from mobile, but the results look good. Layout is comfortable, good margins, well-differentiated bits, and all without being distracting.

I've got a general set of tips most of which you can likely ignore. Check that you're using em/rem rather than px or pt for font sizes: https://www.reddit.com/r/dredmorbius/comments/29eqrk/web_des...

Re: Use Vim Inside a Unix Pipe Like Sed or AWK

#45
post #10

This post hints toward vim's history: the ed family of editors. http://blog.sanctum.geek.nz/actually-using-ed/ http://blog.sanctum.geek.nz/using-more-of-ex/ A big use case for them was using them as scriptable editors in pipelines, and a lot of vim's commands are inherited from them. The diff(1) utility actually has an option to emit ed script, allowing files to be patched in ed pipelines: http://www.gnu.org/software…

It's common for people today to think of ancient Greeks as being very unsophisticated and primitive, but then when you start to read what ancient philosophers wrote you think "Wow, these guys really had things figured out, maybe better than we do now." I kind of feel the same way comparing modern GUI applications to ancient editors like ed.

I get a tiny ping of irritation every time I use an application to do some mundane, repeatable, well-defined task and it doesn't have a CLI.

Re: Use Vim Inside a Unix Pipe Like Sed or AWK

#46
post #10

This post hints toward vim's history: the ed family of editors. http://blog.sanctum.geek.nz/actually-using-ed/ http://blog.sanctum.geek.nz/using-more-of-ex/ A big use case for them was using them as scriptable editors in pipelines, and a lot of vim's commands are inherited from them. The diff(1) utility actually has an option to emit ed script, allowing files to be patched in ed pipelines: http://www.gnu.org/software…

Sort of. While ed was scriptable, it was by sending the commands to stdin, which doesn't lend itself to being composed in a pipeline, where you'd more intuitively expect the text it's modifying to be on stdin. We can do it without problem now, because shells have process substitution, but ed predates that shell feature by a couple of decades. Instead, to use ed in pipelines, we ended up with a modified ed to work on streams: `sed`, the Stream ED.

Re: Use Vim Inside a Unix Pipe Like Sed or AWK

#47

Earlier quoted context omitted.

It's common for people today to think of ancient Greeks as being very unsophisticated and primitive, but then when you start to read what ancient philosophers wrote you think "Wow, these guys really had things figured out, maybe better than we do now." I kind of feel the same way comparing modern GUI applications to ancient editors like ed.

But then you remember that Ed was designed to be used on what essentially was a typewriter, because dialup was so slow, that you couldn't send an entire screen worth of text at once. So you would basically be remembering the text in your head, while inserting and regexing lines. And the great error handling when it doesn't know what you just told it to do. ?

It's not that they had dialup, or that they couldn't send an entire screen at once (though I'm sure these factors later helped keep ed around). The devices they were using were much more like a typewriter than you seem to think, they literally printed the text out on paper! The programmer didn't need to remember the text in their head, they had the paper right there to look at!

Re: Use Vim Inside a Unix Pipe Like Sed or AWK

#49
post #25

Earlier quoted context omitted.

Which philosophers? The only one I've read in any depth is Aristotle, and while he is clearly very smart, I agreed with essentially none of it.

https://en.wikipedia.org/wiki/Lorem_ipsum

I do not understand your reply; Lorem ipsum text is tangentially related to Cicero, but he's Roman, not Greek.
Post reply on HN