Peter Stuifzand

Subversion diff inside Vim

I like using vim. It is simple want it to, but has a lot of possibities when you need them. Like Perl in vim simple things are easy and hard things are possible. Like the following piece of code.

I wanted to see a diff of my current version and the version in my svn repository.

function Svndiff()
    let file = system('tempfile')
    execute 'silent !svn cat ' expand("%") ' > ' file
    execute 'silent vertical diffsplit ' file
endfunction

map <F4> :call Svndiff()<CR>

Of course the <F4> binding is like icing on the already delicious cake. The only thing that I’m not happy about is the problem with the tempfile, that will stay open after you’ve opened the split screen.

© 2023 Peter Stuifzand