How to dump the output of an external command to a new buffer in Vim?

:enew allows me to create a new buffer, and :.! <command > :.! <command > allows me to dump the output of an external command into this buffer. Can I combine two into one liner?

Thanks.

+7
vim
source share
2 answers

'|' used to combine commands together in vim. So

 :enew | .! <command> 

should do what you want

+5
source share

:.! actually passes the current line through an external command, possibly losing the line. You can use :r !<command> - Note the space before ! . I often use :0r !cmd so that the output is inserted at the beginning of the buffer.

+2
source share

All Articles