Live data from Hacker News

Use Vim Inside a Unix Pipe Like Sed or AWK

blog.robertelder.org

31–40 of 49 posts

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

#31
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 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.

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

#32
post #22

How does this compare to piping through Elisp?

This isn't supported at all in emacs by default - or, if it is, I never figured out how.

You can try my pmacs script to get something sort-of-like: https://github.com/tom-seddon/bin/blob/master/pmacs.py (not productized, and some self-assembly may be required - should work out of the box on Linux, though, and probably OS X too)

Works pretty well, though only at the end of a pipeline. (It could probably be extended to work mid-pipeline though; you can get emacsclient to block until the file's buffer is closed in emacs - this is what the "-n" switch inhibits - giving the script a chance to wait, load the (presumably modified) file and print it to stdout.)

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

#33
post #21

Earlier quoted context omitted.

This brings up a side by side comparison of the documents. This is different than the pure diff.

Sure, for that there is also colordiff.

Yeah, there are many other external tools that can accomplish this. Piping directly to Vim just allows us install one less.

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

#35

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…

[deleted]

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

#36
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 haven't used ed, but I'm inclined to agree. People still make fun of me for living in the terminal.

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

#38

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…

The color, layout, and font sizes are quite fine the way they are. The containers for your paragraphs expand to the full width of the screen, no matter the width, which is awesome!

Everything in the linked article is easy to read on my crummy laptop screen. (Its screen makes seeing too-low-contrast color changes [0] rather difficult. The fact that all of your site is legible is a strong indicator that your contrast and color scheme choices are perfectly adequate ones.)

In short, don't change anything about the layout, unless you are really motivated to do so. You've made good choices!

[0] Such as -2 or -3 and below comments on HN.

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

#39

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.

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...

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

#40
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.

Very true. I read Plato's Timmeus for a music theory class once and noticed that along the way of explaining his version of music theory, he also--from first principles only--deduced the existence of fundamental particles. He didn't call then protons, neutrons, and electrons, obviously. Be he got the basic idea correct: that all the things that exist are fundamentally built from the same things.

My mind was constantly being blown in that class.

Post reply on HN