February 3rd 2009

Committing every time you save in Vim

I wonder if there are any non squash-heavy workflows that this goes well with.

" requires vim-python and python-git
function! CommitFile()
python << EOF
import vim, git
curfile = vim.current.buffer.name
if curfile:
    try:
        repo = git.Repo(curfile)
        repo.git.add(curfile)
        repo.git.commit(m='Update')
    except (git.InvalidGitRepositoryError, git.GitCommandError):
        pass
EOF
endfunction
au BufWritePost * call CommitFile()



You can subscribe to new posts via email or RSS.