Skip to content

Instantly share code, notes, and snippets.

@motemen motemen/gist:894232
Created Mar 30, 2011

Embed
What would you like to do?
highlight last change on git
" requires metarw-git
nnoremap <silent> <Leader>gw :silent call GitHighlightLastChange()<CR>
function! GitHighlightLastChange()
if &diff
diffoff
return
endif
let log = system('git log -1 --pretty=oneline ' . expand('%'))
if v:shell_error
echoerr log
return
endif
let [ sha1, message ] = matchlist(log, '\v(\x{40}) (.*)\n')[1:2]
execute 'vertical diffsplit' 'git:' . sha1 . '^:%'
quit
redrawstatus
unsilent echo "highlighting diff of '" . message . "'"
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.