In short, makeprg tells vim how to execute a program when you invoke :make and errorformat instructs vim how to parse the output of the program to load it into the quickfix list.
With these settings, you can run :make on any shell script to run shellcheck and get a list of errors in vim.
Once results are in the quickfix list, you can navigate the errors with :cnext/:cprevious, :cfirst/:clast, or :copen to open the quickfix list.
For convenience, I recommend mapping :cnext and :cprevious to something like ]q and [q. See tpope/vim-unimpaired for mapping inspiration.
Some plugins aim to automatically do all the linting integration heavylifting for you, like ALE, Syntastic, and NeoMake, and some plugins aim provide a Language Server Protocol (LSP) integration in vim, like vim-lsp, coc.nvim, and now neovim with its built-in LSP implementation.
You can implement linting and error checking for your shell scripts as well.
First, create
$HOME/.vim/compiler/shellcheck.vimand put the following configurations in it:You can learn more about this by reading the vim docs on writing a compiler plugin.
In short,
makeprgtells vim how to execute a program when you invoke:makeanderrorformatinstructs vim how to parse the output of the program to load it into the quickfix list.With these settings, you can run
:makeon any shell script to runshellcheckand get a list of errors in vim.Once results are in the quickfix list, you can navigate the errors with
:cnext/:cprevious,:cfirst/:clast, or:copento open the quickfix list.For convenience, I recommend mapping
:cnextand:cpreviousto something like]qand[q. See tpope/vim-unimpaired for mapping inspiration.Some plugins aim to automatically do all the linting integration heavylifting for you, like ALE, Syntastic, and NeoMake, and some plugins aim provide a Language Server Protocol (LSP) integration in vim, like vim-lsp, coc.nvim, and now neovim with its built-in LSP implementation.
WOW! Thats a great suggestion, but I wanted to make it simple for beginners, still a fantastic recommendation :)
I agree with making things simple for beginners. I just wanted to illustrate the possible range of customizability with and without plugins.