I set up my vimrc to use the :make and debugging facilities, adding in support for subversion in the process. I tried svncommand but it didn't work for whatever reason, and I figured I'd learn a bunch by hacking it into my config. You need vim 7 or higher to use the readfile() function in SvnDiff(), so upgrade already! ;)
I also updated the new file initialization to look less lame.
Update 2007-05-13:
I changed out the vim7-only readfile() for vim6-and-maybe-earlier getfsize(). I also changed out the normal mode ",sd" shortcut to a command mode abbreviation.
Update 2007-05-14:
I simplified SvnDiff() to just echo the diff as using QuickFix buffers to store diff entries that have dates (e.g. Mon May 14 22:01:17 GMT 2007) will cause QuickFix to puke.
let g:SvnExecutable="/usr/bin/svn"
let g:SvnEditCommand="vsplit"
" support subversion
" svn diff output goes in the quickfix buffer
" svn commit opens a comment buffer with g:SvnEditCommand and creates callback with an autocmd
" to call SvnCommitPost() on write,
" if you're on windows, you might have to prefix the filenames with \c for case-insensitivity
function SvnDiff()
let diff = system(g:SvnExecutable . " diff " . expand("%") )
if strlen(diff) > 0
echo diff
else
echo "No Difference!"
endif
endfunction
function SvnCommit()
let file = expand('%')
let mesg = tempname()
execute g:SvnEditCommand . ' ' . mesg
execute "augroup Svn"
execute "autocmd!"
execute 'autocmd BufWritePost ' . mesg . ' call SvnCommitPost("' . file . '","' . mesg . '")'
execute "augroup END"
startinsert
endfunction
function SvnCommitPost(file, mesg)
execute 'bd'
echo system(g:SvnExecutable . ' commit -F ' . a:mesg . ' ' . a:file)
execute delete(a:mesg)
endfunction
" map subversion
if exists('g:SvnExecutable')
cabbr svnd call SvnDiff()
cabbr svnc call SvnCommit()
endif
" new file? fill it with a skeleton
function InitNewFile(type)
if a:type == "py"
execute setline(1, "#!/usr/bin/python")
elseif a:type == "pl"
execute setline(1, ["#!/usr/bin/perl", "use warnings;", "use strict;"])
elseif a:type == "sh"
execute setline(1, "#!/bin/bash")
endif
execute "normal Go"
startinsert
endfunction
" empty autocmd and re-fill
if has("autocmd")
autocmd!
autocmd BufNewFile *.py call InitNewFile("py")
autocmd BufNewFile *.sh call InitNewFile("sh")
autocmd BufNewFile *.pl call InitNewFile("pl")
endif