How to automatically execute a shell command after saving a file in Vim?

我是研究僧i 提交于 2019-11-27 09:45:56

问题


This is because I'd like to automatically run tests after each file save.

I have looked at autocmd and BufWritePost but cannot make it work.


回答1:


This runs run_tests.sh after any file is saved, with the current filename as the only parameter:

:autocmd BufWritePost * !run_tests.sh <afile>

View the auto-command with:

:autocmd BufWritePost *

And remove all auto-commands from the previous with:

:autocmd! BufWritePost *


来源:https://stackoverflow.com/questions/4627701/how-to-automatically-execute-a-shell-command-after-saving-a-file-in-vim

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!