1
0
Fork 0
mirror of synced 2024-11-13 20:58:57 -05:00
ultimate-vim/functions/Vimdiff.vim
2017-12-04 20:09:55 +08:00

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>