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.
Go to command mode Esc , then run :! unix_command . Anything run from the : prompt starting with a bang ! will be run as a unix shell command. You'll be shown the output and allowed to hit a key to get back to your work in vim.
Introduction *autocmd-intro* You can specify commands to be executed automatically when reading or writing a file, when entering or leaving a buffer or window, and when exiting Vim. For example, you can create an autocommand to set the 'cindent' option for files matching *.c.
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 *
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With