Is there any way to hook saving in Vim up to commiting in git? This version works only if you are in the root directory of your repo. A better solution is autocmd BufWritePost * execute '! if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1 ; then git add % ; git commit -m %; fi', from a SO answer