diff --git a/doc/fugitive.txt b/doc/fugitive.txt index a098297..d7038e7 100644 --- a/doc/fugitive.txt +++ b/doc/fugitive.txt @@ -175,6 +175,9 @@ that are part of Git repositories). along to git-blame. The following maps, which work on the cursor line commit where sensible, are provided: + A resize to end of author column + C resize to end of commit column + D resize to end of date/time column q close blame and return to blamed window gq q, then |:Gedit| to return to work tree version i q, then open commit diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 96cd1d6..a03cfb8 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -1513,6 +1513,10 @@ augroup fugitive_blame autocmd User Fugitive if s:buffer().type('file', 'blob') | exe "command! -buffer -bar -bang -range=0 -nargs=* Gblame :execute s:Blame(0,,,,[])" | endif augroup END +function! s:linechars(pattern) + return strlen(s:gsub(matchstr(getline('.'), a:pattern), '.', '.')) +endfunction + function! s:Blame(bang,line1,line2,count,args) abort try if s:buffer().path() == '' @@ -1577,7 +1581,7 @@ function! s:Blame(bang,line1,line2,count,args) abort execute top normal! zt execute current - execute "vertical resize ".(match(getline('.'),'\s\+\d\+)')+1) + execute "vertical resize ".(s:linechars('.\{-\}\d\ze\s\+\d\+)')+1) setlocal nomodified nomodifiable nonumber scrollbind nowrap foldcolumn=0 nofoldenable filetype=fugitiveblame if exists('+relativenumber') setlocal norelativenumber @@ -1591,6 +1595,9 @@ function! s:Blame(bang,line1,line2,count,args) abort nnoremap i :exe BlameCommit("exe 'norm q'edit") nnoremap o :exe BlameCommit((&splitbelow ? "botright" : "topleft")." split") nnoremap O :exe BlameCommit("tabedit") + nnoremap A :exe "vertical resize ".(linechars('.\{-\}\ze \d\{4\}-\d\d-\d\d ')+1) + nnoremap C :exe "vertical resize ".(linechars('^\S\+')+1) + nnoremap D :exe "vertical resize ".(linechars('.\{-\}\ze\d\ze\s\+\d\+)')+1) redraw syncbind endif