This solution is totally inspired from romainl's one (many thanks to him) but it allows to open multiple buffers with multiple strings.
Add the following lines to your .zshrc (or .bashrc or any relevant file where you define your bash functions)
function mvim {
CMD="vim "
for string in "$@"
do
CMD=$CMD"-c \"enew | put='"$string"'\" "
done
CMD=$CMD"-c \"bufdo 1d\""
eval $CMD
}
After sourcing your .zshrc file you'll be able to call the following function:
mvim "foo bar" "baz" "and quz"
Which will open a vim instance with 3 buffers, each one containing one string.
If no argument is provided a regular vim instance will be started. If one argument is an empty string, an empty buffer will be created.
EDIT I realized that for a reason that I don't understand an empty line is created at the beginning of each buffer so I added the line
CMD=$CMD"-c \"bufdo 1d\""
To get rid of this empty line in all buffers.
vim < echo "test"but with no success. I did not know aboutvim -! And+/-ccan be useful too. Thank you. – Gonçalo Ribeiro Aug 29 '15 at 20:58