From 3933bfdc57396f6f24f64f5ad0110d8694f11459 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sun, 27 Feb 2011 13:14:58 -0500 Subject: [PATCH] Prefer ds to dh for horizontal diff map --- doc/fugitive.txt | 2 +- plugin/fugitive.vim | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/doc/fugitive.txt b/doc/fugitive.txt index f7a340b..5a10ba2 100644 --- a/doc/fugitive.txt +++ b/doc/fugitive.txt @@ -54,7 +54,7 @@ that are part of Git repositories). window. In addition to standard motions, you can use and to jump from filename to filename. Press D to |:Gdiff| the file on the cursor - line, or dh to |:Gdiff!|. Press - to stage or unstage + line, or ds to |:Gsdiff|. Press - to stage or unstage the file on the cursor line. Press p to do so on a per hunk basis (--patch). Press C to invoke |:Gcommit|. diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 7b2e0e7..13b6279 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -565,7 +565,8 @@ function! fugitive#reload_status() abort endfor endfunction -function! s:StageDiff(bang) abort +function! s:StageDiff(...) abort + let cmd = a:0 ? a:1 : 'Gdiff' let section = getline(search('^# .*:$','bnW')) let line = getline('.') let filename = matchstr(line,'^#\t\%([[:alpha:] ]\+: *\)\=\zs.\{-\}\ze\%( (new commits)\)\=$') @@ -576,13 +577,13 @@ function! s:StageDiff(bang) abort elseif line =~# '^#\trenamed:' && filename =~ ' -> ' let [old, new] = split(filename,' -> ') execute 'Gedit '.s:fnameescape(':0:'.new) - return 'Gdiff'.a:bang.' HEAD:'.s:fnameescape(old) + return cmd.' HEAD:'.s:fnameescape(old) elseif section == '# Changes to be committed:' execute 'Gedit '.s:fnameescape(':0:'.filename) - return 'Gdiff'.a:bang.' -' + return cmd.' -' else execute 'Gedit '.s:fnameescape('/'.filename) - return 'Gdiff'.a:bang + return cmd endif endfunction @@ -1625,9 +1626,11 @@ function! s:BufReadIndex() setlocal ro noma nomod nomodeline bufhidden=delete nnoremap a :let b:fugitive_display_format += 1exe BufReadIndex() nnoremap i :let b:fugitive_display_format -= 1exe BufReadIndex() - nnoremap D :execute StageDiff('') - nnoremap dd :execute StageDiff('') - nnoremap dh :execute StageDiff('!') + nnoremap D :execute StageDiff() + nnoremap dd :execute StageDiff() + nnoremap dh :execute StageDiff('Gsdiff') + nnoremap ds :execute StageDiff('Gsdiff') + nnoremap dv :execute StageDiff() nnoremap - :execute StageToggle(line('.'),line('.')+v:count1-1) xnoremap - :execute StageToggle(line("'<"),line("'>")) nnoremap p :execute StagePatch(line('.'),line('.')+v:count1-1)