0

I am trying to run shellcheck upon exiting vim, however I do not get the output of the command I run.

I've tested running something like touch foo instead, and I managed to see the file being created, so it seems the problem is that the output is written elsewhere and cleared up on exit.

So far I've tried this (and some variants) in my .vimrc:

au bufwinleave *.sh call system("shellcheck %")
au bufwinleave *.sh exec "!shellcheck %"
3
  • You're trying to have the command's output show up in the shell after Vim exits? That's not possible. Vim is a child process of the shell and a child can't cause anything to happen in the parent's stdout after it exits. And the output of a process launched from Vim is controlled by Vim...it doesn't go to the parent's stdout either. You can either view the output in Vim and then exit or you can call shellcheck from the shell after exiting Vim.
    – B Layer
    Jan 14 at 3:58
  • (It's sort of irrelevant given the above but a) BufWinLeave is not right as that gets triggered for reasons other than exiting Vim and b) even if it were right you shouldn't use % with it as it might not be what you expect....you need to use <afile>.)
    – B Layer
    Jan 14 at 4:05
  • I would suggest you have shellcheck's output written to a file and then you can view that file after Vim exits. (In which case the first item in my second comment will become relevant...pick a better event from :h autocommand-events.)
    – B Layer
    Jan 14 at 4:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.