let s:winnr=[]
fu! <sid>ReadFile(file)
let s:diff_file=readfile(a:file)
endfu
fu! <sid>Files(next)
if a:next > 0
let s:line=(s:line+1) % len(s:diff_file)
else
let s:line=(s:line-1) % len(s:diff_file)
endif
let val = split(s:diff_file[s:line])
return val
endfu
fu! <sid>MapKeys(map)
if a:map
map <C-N> :call <sid>Main(1)<cr>
map <C-P> :call <sid>Main(-1)<cr>
else
unmap <C-N>
unmap <C-P>
endif
endfu
fu! <sid>Main(next)
if !exists("s:loaded")
let files=<sid>Files(1)
call add(s:winnr, winnr())
exe "e" files[0]
exe "vsp " files[1]
call add(s:winnr, winnr()+1)
windo diffthis
call <sid>MapKeys(1)
let s:loaded=1
else
exe s:winnr[0] . "wincmd w "
diffo
let files=<sid>Files(a:next)
exe "e" files[0]
exe s:winnr[1] . "wincmd w "
diffo
exe "e" files[1]
windo diffthis
endif
endfu
com! -nargs=1 -complete=file VimDiffFiles :call <sid>ReadFile(<f-args>)|:call <sid>Main(1)
com! -complete=file VimDiffOff :call <sid>MapKeys(0)|windo diffo
Hi viki!
On Mi, 07 Apr 2010, viki wrote:
> I have file containing >20 pairs of pathnames, one pair per line:
>
> /path1/to/file1.OLD /path2/to.file1.NEW
> etc.
>
> I need to open vimdiff on multiple pairs of files
> such that I can switch forward to next pair, backward to
> previous pair, each time seeing vimdiff of that pair.
> How can I do it ? Is there a plugin that does such thing ?
Try the attached script. It expects no whitespace in the filenames and 2
files per line or else it will probably fail.
regards,
Christian
--
Wir Menschen lieben nicht, um zu hassen; aber wohl hassen wir, um zu
lieben.
-- Jean Paul
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
To unsubscribe, reply using "remove me" as the subject.
No comments:
Post a Comment