Loom
Loom

Reputation: 9986

How to open in vim output of some app

Sometimes, I'd like to see output source code and standard output of compiled version of this code in vim simultaneously. Let's say, I have code source.cpp and compiled app main. Of course I can redirect main output to file and open it in vim:

 $ main > /tmp/main_output.txt
 $ vim /tmp/main_output.txt

However, it is too boring (especially if you have a lot of pairs code/app). So I'd like to write in vim something like

 :e source.cpp
 :vsp <someway obtained output of main>

How I can obtain it?

Upvotes: 1

Views: 39

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172540

Just create a new scratch buffer (:new) and use :read !{cmd} to execute an external command and use its output:

:e source.cpp
:vnew | 0r !main

Upvotes: 2

Related Questions