且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Vim 中保存文件后如何自动执行 shell 命令?

更新时间:2023-10-28 09:29:10

这会在保存任何文件后运行 run_tests.sh,以当前文件名作为唯一参数:

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

:autocmd BufWritePost * !run_tests.sh <afile>

查看自动命令:

:autocmd BufWritePost *

并删除之前的所有自动命令:

And remove all auto-commands from the previous with:

:autocmd! BufWritePost *