Prefer ds to dh for horizontal diff map

This commit is contained in:
Tim Pope 2011-02-27 13:14:58 -05:00
parent fe7f04ebdf
commit 3933bfdc57
2 changed files with 11 additions and 8 deletions

View File

@ -54,7 +54,7 @@ that are part of Git repositories).
window. In addition to standard motions, you can window. In addition to standard motions, you can
use <C-N> and <C-P> to jump from filename to use <C-N> and <C-P> to jump from filename to
filename. Press D to |:Gdiff| the file on the cursor 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 the file on the cursor line. Press p to do so on a
per hunk basis (--patch). Press C to invoke per hunk basis (--patch). Press C to invoke
|:Gcommit|. |:Gcommit|.

View File

@ -565,7 +565,8 @@ function! fugitive#reload_status() abort
endfor endfor
endfunction endfunction
function! s:StageDiff(bang) abort function! s:StageDiff(...) abort
let cmd = a:0 ? a:1 : 'Gdiff'
let section = getline(search('^# .*:$','bnW')) let section = getline(search('^# .*:$','bnW'))
let line = getline('.') let line = getline('.')
let filename = matchstr(line,'^#\t\%([[:alpha:] ]\+: *\)\=\zs.\{-\}\ze\%( (new commits)\)\=$') let filename = matchstr(line,'^#\t\%([[:alpha:] ]\+: *\)\=\zs.\{-\}\ze\%( (new commits)\)\=$')
@ -576,13 +577,13 @@ function! s:StageDiff(bang) abort
elseif line =~# '^#\trenamed:' && filename =~ ' -> ' elseif line =~# '^#\trenamed:' && filename =~ ' -> '
let [old, new] = split(filename,' -> ') let [old, new] = split(filename,' -> ')
execute 'Gedit '.s:fnameescape(':0:'.new) 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:' elseif section == '# Changes to be committed:'
execute 'Gedit '.s:fnameescape(':0:'.filename) execute 'Gedit '.s:fnameescape(':0:'.filename)
return 'Gdiff'.a:bang.' -' return cmd.' -'
else else
execute 'Gedit '.s:fnameescape('/'.filename) execute 'Gedit '.s:fnameescape('/'.filename)
return 'Gdiff'.a:bang return cmd
endif endif
endfunction endfunction
@ -1625,9 +1626,11 @@ function! s:BufReadIndex()
setlocal ro noma nomod nomodeline bufhidden=delete setlocal ro noma nomod nomodeline bufhidden=delete
nnoremap <buffer> <silent> a :<C-U>let b:fugitive_display_format += 1<Bar>exe <SID>BufReadIndex()<CR> nnoremap <buffer> <silent> a :<C-U>let b:fugitive_display_format += 1<Bar>exe <SID>BufReadIndex()<CR>
nnoremap <buffer> <silent> i :<C-U>let b:fugitive_display_format -= 1<Bar>exe <SID>BufReadIndex()<CR> nnoremap <buffer> <silent> i :<C-U>let b:fugitive_display_format -= 1<Bar>exe <SID>BufReadIndex()<CR>
nnoremap <buffer> <silent> D :<C-U>execute <SID>StageDiff('')<CR> nnoremap <buffer> <silent> D :<C-U>execute <SID>StageDiff()<CR>
nnoremap <buffer> <silent> dd :<C-U>execute <SID>StageDiff('')<CR> nnoremap <buffer> <silent> dd :<C-U>execute <SID>StageDiff()<CR>
nnoremap <buffer> <silent> dh :<C-U>execute <SID>StageDiff('!')<CR> nnoremap <buffer> <silent> dh :<C-U>execute <SID>StageDiff('Gsdiff')<CR>
nnoremap <buffer> <silent> ds :<C-U>execute <SID>StageDiff('Gsdiff')<CR>
nnoremap <buffer> <silent> dv :<C-U>execute <SID>StageDiff()<CR>
nnoremap <buffer> <silent> - :<C-U>execute <SID>StageToggle(line('.'),line('.')+v:count1-1)<CR> nnoremap <buffer> <silent> - :<C-U>execute <SID>StageToggle(line('.'),line('.')+v:count1-1)<CR>
xnoremap <buffer> <silent> - :<C-U>execute <SID>StageToggle(line("'<"),line("'>"))<CR> xnoremap <buffer> <silent> - :<C-U>execute <SID>StageToggle(line("'<"),line("'>"))<CR>
nnoremap <buffer> <silent> p :<C-U>execute <SID>StagePatch(line('.'),line('.')+v:count1-1)<CR> nnoremap <buffer> <silent> p :<C-U>execute <SID>StagePatch(line('.'),line('.')+v:count1-1)<CR>