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.

9
  • 1
    See github.com/juliangruber/vipe
    – romainl
    Jan 30 at 6: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 at 7:31
  • 2
    @romainl Why? I think this is a good question, why do you want to close it?
    – Bog
    Jan 30 at 10:13
  • 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 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 at 8:48

1 Answer 1

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.