Thursday, October 15, 2015

Re: Capture output of :make

On Thursday, October 15, 2015 at 4:05:55 AM UTC-5, Nicola wrote:
> Is it possible to capture the output of :make in order to show it
> in a buffer (when there are no errors)?
>
> My use case is as follows: I have some files that I want to process
> to produce reports. But the files may contain syntax errors, in which
> case I'd like such errors to be sent to a quickfix window.
>
> What I am doing now is setting the global errorformat and using cexpr,
> along these lines:
>
> let output = system(cmd)
> if v:shell_error
> set errorformat=%f:%l:%m
> cexpr output
> copen
> else
> bo new
> call append(0, output)
> endif
>
> This works, but I have to set the global errorformat, which I am not
> sure is a good thing (say, if I want to distribute the code as a plugin).
> Is there a better way?
>
> Nicola

I'm confused. Pretty much the ENTIRE POINT of quickfix is capturing the output of :make (and :grep/:vimgrep I suppose, but it's called "quickfix" because it lets you quickly fix compiler errors).

If you're writing a new plugin to capture output for a particular compiler, you'll want to look at :help write-compiler-plugin

If you are using a fairly standard compiler, you should check if Vim already has a compiler plugin available. If so, you would use it (for example) like this to view the errors in a buffer without jumping immediately:

:compiler! gcc
:make!
:copen

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: