aboutsummaryrefslogtreecommitdiffstats
path: root/bundle/git-blamer/autoload/git_blamer.vim
diff options
context:
space:
mode:
authorTeddy Wing2018-03-28 00:50:47 +0200
committerTeddy Wing2018-03-28 00:50:47 +0200
commitaee838fefd2dd878915e14de0380731482b08e6d (patch)
treea1029f27cc6052f445f8c6d8add954a1c3643538 /bundle/git-blamer/autoload/git_blamer.vim
parent019805f339a0774574d97f138ea2b2c9425db0b4 (diff)
downloaddotvim-aee838fefd2dd878915e14de0380731482b08e6d.tar.bz2
git-blamer: Run `git show` on <Enter>
When the `<Enter>` key is pressed in the GitBlamer window, run `!git show` on the commit from the current cursor line of the blame. This allows a changed line to be inspected in the context of its original changeset. It also saves me time from my previous workflow: cpe^Zgit show <Apple-P><Enter>
Diffstat (limited to 'bundle/git-blamer/autoload/git_blamer.vim')
-rw-r--r--bundle/git-blamer/autoload/git_blamer.vim10
1 files changed, 10 insertions, 0 deletions
diff --git a/bundle/git-blamer/autoload/git_blamer.vim b/bundle/git-blamer/autoload/git_blamer.vim
index df9832e..8245986 100644
--- a/bundle/git-blamer/autoload/git_blamer.vim
+++ b/bundle/git-blamer/autoload/git_blamer.vim
@@ -41,6 +41,7 @@ function! git_blamer#Blame()
syncbind
nnoremap <buffer> q :q<CR>
+ nnoremap <buffer> <Enter> :call <SID>GitShow()<CR>
" Restore starting file's scrollbind on exit
autocmd BufWinLeave <buffer>
@@ -63,3 +64,12 @@ function! s:RemoveWindowFocusAutocmd()
autocmd!
augroup END
endfunction
+
+function! s:GitShow()
+ execute '!git show ' . s:CommitSHAFromLine('.')
+endfunction
+
+function! s:CommitSHAFromLine(line)
+ let current_line = getline(a:line)
+ return matchstr(current_line, '\v^[0-9a-f]+')
+endfunction