Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vim

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

Thanks.

like image 735
Kevin Avatar asked Sep 29 '10 21:09

Kevin


2 Answers

'|' is used to chain commands together in vim. so

:enew | .! <command>

should do what you want

like image 163
Matt Briggs Avatar answered Sep 27 '22 19:09

Matt Briggs


:.! actually pipes the current line through the external command, possibly losing the line. You may wish to use :r !<command>—Note the space before the !. I often use :0r !cmd so that the output is inserted at the start of the buffer.

like image 31
bobbogo Avatar answered Sep 27 '22 19:09

bobbogo