How to use quickfix in Vim to debug Bash scripts

痴心易碎 提交于 2019-12-03 06:43:42

Vim's quickfix window is designed to speed up the edit-compile-edit cycle. Since Bash scripts do not get compiled, we have to substitute something else for that step that can point out errors in the current script.

What you want is a static analysis tool for Bash scripts. There are two good ones: shellcheck and checkbashisms. You'll want to install at least shellcheck, as it's the more comprehensive of the pair, but installing checkbashisms will help catch a few more issues.

To integrate those two tools into Vim, you need a plugin called Syntastic. Check the project page for installation instructions.

Once you've got everything installed, you'll be able to get immediate feedback on basic issues in your Bash script:

  • Use :SyntasticCheck to force the checker to run
  • If you want the "quickfix" window to appear, run :Errors
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!