28 lines
670 B
VimL
28 lines
670 B
VimL
" see: https://brookhong.github.io/2016/09/03/view-diff-file-side-by-side-in-vim.html
|
|
|
|
function! Vimdiff()
|
|
let lines = getline(0, '$')
|
|
let la = []
|
|
let lb = []
|
|
for line in lines
|
|
if line[0] == '-'
|
|
call add(la, line[1:])
|
|
elseif line[0] == '+'
|
|
call add(lb, line[1:])
|
|
else
|
|
call add(la, line)
|
|
call add(lb, line)
|
|
endif
|
|
endfor
|
|
tabnew
|
|
set bt=nofile
|
|
vertical new
|
|
set bt=nofile
|
|
call append(0, la)
|
|
diffthis
|
|
exe "normal \<C-W>l"
|
|
call append(0, lb)
|
|
diffthis
|
|
endfunction
|
|
autocmd FileType diff nnoremap <silent> <leader>vd :call Vimdiff()<CR>
|
|
|