Is it possible to open vim with stdin in one window, and a file in another?

vim - starts vim with text from stdin in the buffer

vim -o file1 file2 starts vim with files in multiple split windows

Can they be combined? vim -o file1 - doesn't work; it dies with a Too many edit arguments error. I know I can use vim - and then :split file1, but I'd like to do it with command-line flags if possible.


Though you cannot use -o, you can execute any commands passed with -c:

$ vim - -c 'split file1'

I just found out another cool way to open from multiple temporary files (without reading from stdin, though):

vim -O <(sort file1) <(sort file2) (split)

vim -p <(sort file1) <(sort file2) (tabbed)

Of course you can execute any command within the brackets:

vim -O <(cat file1) <(cat file2)

(Inspired by https://unix.stackexchange.com/questions/16443/combine-text-files-column-wise)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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