Last active
January 5, 2017 21:07
-
-
Save mageekguy/4713903 to your computer and use it in GitHub Desktop.
Add code below in your .vimrc to see the Git previous version of the current file with :GitPrevious.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:GitPrevious() | |
let _ = './' . expand('%') | |
let filetype = &filetype | |
execute ':silent! vsp ' . tempname() | |
execute ':silent! 0r !git show HEAD~1:' . _ | |
execute ':silent! $d' | |
execute ':silent! set nomodifiable' | |
execute ':silent! set readonly' | |
execute ':silent! set ft=' . filetype | |
setlocal buftype=nowrite bufhidden=wipe nobuflisted noswapfile | |
endfunction | |
command! -nargs=0 GitPrevious call s:GitPrevious() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment