DBedrenko
DBedrenko

Reputation: 5029

How to check multiple files at once?

Currently, if I run :SyntasticCheck, :Errors displays errors for the current buffer only. What I want it to do is to check all Python (*.py) files in the current working directory, and so that all the locations are aggregated in a single LocationList.

I know this is possible because the Syntastic documentation implies it, e.g. there is a syntastic_ignore_files setting for ignoring patterns of filenames.


My failed attempt:

  1. Set let g:syntastic_aggregate_errors = 1
  2. Open all *.py files with :n *.py
  3. :bufdo SyntasticCheck
  4. It cycles through each buffer and runs the check. However, when this is finished :Errors shows errors only for the last buffer that was checked.

Upvotes: 2

Views: 496

Answers (2)

Nick Myatt
Nick Myatt

Reputation: 11

Vim supports errorfiles, so if your underlying checker can output a list of errors in the format expected by Vim, just run vim -q [errorfile] and the quickfix list will be populated with all the errors. You can cycle through the locations in the quickfix list (e.g. using :cn) and Vim will open the corresponding files for you as you go.

Upvotes: 1

lcd047
lcd047

Reputation: 5861

Currently, if I run :SyntasticCheck, :Errors displays errors for the current buffer only. What I want it to do is to check all Python (*.py) files in the current working directory, and so that all the locations are aggregated in a single LocationList.

This is not possible, and there is currently no plan to implement it.

I know this is possible because the Syntastic documentation implies it, e.g. there is a syntastic_ignore_files setting for ignoring patterns of filenames.

Some checkers check include files and the like, and sometimes you may not care about errors there. Also, there are situations when you don't want to check certain files automatically (this is generally useful when you have active mode enabled).

let g:syntastic_aggregate_errors = 1

This aggregates errors when running different checkers against the same file. It doesn't aggregate errors when running the same checker against a set of files.

It cycles through each buffer and runs the check. However, when this is finished :Errors shows errors only for the last buffer that was checked.

Yes, :Errors shows the error window for the current buffer.

You might set g:syntastic_check_on_open and active mode and open the files in separate windows. That would run checks against all files, but the results would still be per file, not global. And window positions would be screwed up because of limitations in Vim's API. Basically, there is no way to do what you want if the checker you're running doesn't already check all files by itself.

Upvotes: 2

Related Questions