0

Say I do the following in my shell (but where cat is actually another command that does meaningful work with stdin):

$ cat | very | long | pipeline
typing some
input lines
here...
^D
$

However, my shell's line-editing interface is not as nice as vim. I am looking for some sort of vim commandline option so I can do something like this:

$ vim --some-magic-option-here | very | long | pipeline

Basically, I want vim to open with an empty buffer, and, upon exiting, dump the contents of that buffer to stdout.

  • 1
    See https://github.com/juliangruber/vipe – romainl Jan 30 '24 at 06:19
  • I’m voting to close this question because Google exists. – romainl Jan 30 '24 at 06:19
  • 1
    Welcome to Vi and Vim SE. Did you take a look at bash's vi mode (set -o vi)? Would that solve your problem? – Friedrich Jan 30 '24 at 07:31
  • 2
    @romainl Why? I think this is a good question, why do you want to close it? – Bog Jan 30 '24 at 10:13
  • Yes, but a question OP can answer themselves easily. – romainl Jan 30 '24 at 10:46
  • 3
    @romainl I'm not convinced by the close reason "because Google exists". If we refuse to take any questions that could be answered by Google or :help, we would be left with nothing but the eyebrow raising questions. And Google only feeds on the content we generate. – Friedrich Jan 30 '24 at 12:35
  • 1
    Auto-answerable questions have nothing to do here or anywhere. If you wonder if $PROGRAM has $FEATURE you check its documentation, end of the story. There is no point in involving anyone else unless you find the documentation unclear or you somehow can't make it work. In this case, the answer is just a $ vim --help away. Get a grip. – romainl Jan 31 '24 at 08:48
  • 1
    @romainl this is getting fun. Aren't all questions auto-answerable if you just invest enough time? I like to do my research - different people go and ask. Because people are people. Also, did it ever occur to you that you might find certain things easy other people would find hard? – Friedrich Jan 31 '24 at 21:17
  • 1
    Take it to [meta], folks, if you want to debate site policy. – D. Ben Knoble Feb 04 '24 at 16:50

1 Answers1

0

I second the use of the vipe program in these contexts (often part of the moreutils software package). From the manpage:

vipe allows you to run your editor in the middle of a unix pipeline and edit the
data that is being piped between programs. Your editor will have the full data
being piped from command1 loaded into it, and when you close it, that data will
be piped into command2.

I actually use this for a pbed function in my shell, whose definition (on macOS) is just pbpaste | vipe | pbcopy.

I can also confirm that </dev/null vipe | … works.

D. Ben Knoble
  • 26,070
  • 3
  • 29
  • 65