A tiny Vim plugin for interactive Git rebasing

One of Git’s killer features is interactive rebase. After choosing a range of commits and rebasing them interactively with

git rebase -i HEAD~10

you can re-order, edit, drop and squash commits, simply by fiddling with the list of commits pasted into your favorite editor. Some actions are easily done in Vim (e.g. deleting or moving lines), others require writing whatever you intend to do with the commit. Because I squash a lot, I became tired of typing ^cws over and over again and finally sat down to write this stupid little filetype plugin:

function RebaseActionToggle()
    let line = getline(".")
    let result = matchstr(line, "^\\a")
    let transitions = {'p': 'squash', 's': 'edit', 'e': 'fixup', 'f': 'pick'}
    execute "normal! ^cw" . transitions[result]

noremap <Cr> :call RebaseActionToggle()<Cr>

If you save it as gitrebase.vim in .vim/after/ftplugin, you can cycle through the different rebase actions by pressing Enter:

Have fun with that.