Vim external command output to new buffer

Hi,

From inside Vim, I'm looking for a way to use the contents of the current buffer, pass it to an external executable, and then return the output from the executable into a new Vim buffer.

I know that I can do something like %!<executable>, but that will overwrite the contents of the current buffer.

Thanks in advance!

Copy the original to another buffer first?

Thanks for the reply, but is there a more direct solution?

Your suggestion seems like more of a workaround.

Thanks.

Create a macro to do it all at once? Vim buffers are like files, so :w name and :e name create file 'name' and switch the buffer to the new file. I do not see any fancy buffer-switch or other-buffer commands. There are many vim extensions and plugins, though. This looked a bit interesting:

minibufexpl.vim - Elegant buffer explorer - takes very little screen space : vim online

Vim buffer FAQ - Vim Tips Wiki

Easier buffer switching - Vim Tips Wiki

scratch.vim - Plugin to create and use a scratch Vim buffer : vim online