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

StackOverflow https://stackoverflow.com/questions/4627701

  •  30-09-2019
  •  | 
  •  

Pergunta

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.

Foi útil?

Solução

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 *
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top