Skip to content

Instantly share code, notes, and snippets.

@Altreus
Created December 18, 2013 11:15
Show Gist options
  • Save Altreus/8020689 to your computer and use it in GitHub Desktop.
Save Altreus/8020689 to your computer and use it in GitHub Desktop.
function! GitDiff()
let l:myft = &filetype
diffthis
" deal with submodules by temporarily changing to the file's dir
cd %:p:h
vnew | 0r !git show HEAD:./#:t
norm 1G
exec 'set ft=' . l:myft
set nomod ro
" q to get rid
map <buffer> q :quit<CR> :diffoff<CR>
diffthis
cd -
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment