Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a way to see output of previous ":! g++ %" without rerunning?

Tags:

vim

When coding, I like to check the code by running :! g++ %. I map the command to <F5>. sometimes it takes a while to compile and I want to see the errors without spending time recompiling. Also, sometimes I want to compare the new output to previous one.

Is there a way to see the previous output of :! ...?

like image 778
kirill_igum Avatar asked Mar 07 '12 20:03

kirill_igum


1 Answers

Provided you have g++ configured with makeprg, you can use :copen to reopen the last list of errors from the :make command.

set makeprg=g++\ %

Then, to compile, use

:make

When the compile completes, any errors will be listed in the quickfix window, which can (assuming errorformat is correctly configured) be used to jump to the lines on which errors occur. This usually works out of the box for C/C++.

If you dismiss the quickfix window, retrieve the last error list with

:copen

Review :help quickfix and :help makeprg for full gory details on how this works.

like image 71
Michael Berkowski Avatar answered Sep 27 '22 17:09

Michael Berkowski