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.
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.
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 *
filereadable()
to test if there is a file and then act accordingly. –
Afterimage :autocmd BufWritePost * silent !run_tests.sh <afile>
. Output will still be written to the console, but vim won't wait for you to acknowledge. Send a "quiet"/"silent" option to your specific command or add >/dev/null
to blackhole its output if need be. –
Orelle BufWritePre
–
Antitragus put this into your .vimrc
file:
(take raml2html doc/api.raml > public/api_doc.html
as a command example)
autocmd BufWritePost,FileWritePost *.raml silent! !raml2html doc/api.raml > public/api_doc.html
notice:
silent!
will hide all the output of this command:silent
if you are using vim7.3-, and silent!
if using vim7.3+.vimrc
take effect.© 2022 - 2024 — McMap. All rights reserved.