要扩展 Ingo 的解决方案:
command! -range=-1 -nargs=+ DG for bufspec in [<f-args>] | execute (<count> == -1 ? '' : '<line1>,<line2>') . 'diffget' bufspec | endfor
command! -range=-1 -nargs=* DGA for bufspec in map(filter(range(1, winnr('$')), 'getwinvar(v:val, "&diff")'), 'winbufnr(v:val)') | execute (<count> == -1 ? '' : '<line1>,<line2>') . 'diffget' bufspec | endfor
command! -range=-1 -nargs=+ DP for bufspec in [<f-args>] | execute (<count> == -1 ? '' : '<line1>,<line2>') . 'diffput' bufspec | endfor
command! -range=-1 -nargs=* DPA for bufspec in map(filter(range(1, winnr('$')), 'getwinvar(v:val, "&diff")'), 'winbufnr(v:val)') | execute (<count> == -1 ? '' : '<line1>,<line2>') . 'diffput' bufspec | endfor