Browse files

Add maps for resizing blame window

  • Loading branch information...
1 parent 49c6be3 commit 3b278277e0b46711c30a3d1a0083e527b2fb98ed @tpope committed Jun 22, 2012
Showing with 11 additions and 1 deletion.
  1. +3 −0 doc/fugitive.txt
  2. +8 −1 plugin/fugitive.vim
@@ -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
@@ -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(<bang>0,<line1>,<line2>,<count>,[<f-args>])" | endif
augroup END
+function! s:linechars(pattern)
+ return strlen(s:gsub(matchstr(getline('.'), a:pattern), '.', '.'))
function! s:Blame(bang,line1,line2,count,args) abort
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 <buffer> <silent> i :<C-U>exe <SID>BlameCommit("exe 'norm q'<Bar>edit")<CR>
nnoremap <buffer> <silent> o :<C-U>exe <SID>BlameCommit((&splitbelow ? "botright" : "topleft")." split")<CR>
nnoremap <buffer> <silent> O :<C-U>exe <SID>BlameCommit("tabedit")<CR>
+ nnoremap <buffer> <silent> A :<C-u>exe "vertical resize ".(<SID>linechars('.\{-\}\ze \d\{4\}-\d\d-\d\d ')+1)<CR>
+ nnoremap <buffer> <silent> C :<C-u>exe "vertical resize ".(<SID>linechars('^\S\+')+1)<CR>
+ nnoremap <buffer> <silent> D :<C-u>exe "vertical resize ".(<SID>linechars('.\{-\}\ze\d\ze\s\+\d\+)')+1)<CR>

0 comments on commit 3b27827

Please sign in to comment.