autocmd BufNewFile,BufRead *.p? so ~/.vim/perltest.vim autocmd BufEnter *.p? colors peachpuff autocmd BufNewFile,BufRead *.t so ~/.vim/perltest.vim autocmd BufEnter *.t colors blue #### " perltest.vim - test driven development for Perl with vim " " ,t -- Run tests " ,w -- Set current file as test file. Only this test will run. " ,W -- Unset current test file. All tests will run. " " Updates at http://perlmonks.org/index.pl?node_id=434793 function! Prove ( verbose ) if ! exists("g:testfile") let g:testfile = "t/" endif if g:testfile == "t/" || g:testfile =~ "\.t$" if a:verbose echo system("prove -vl " . g:testfile . " 2>&1 | tee " . &errorfile) else echo system("prove -l " . g:testfile . " 2>&1 | tee " . &errorfile) endif else call Compile () endif cfile endfunction function! Compile () if ! exists("g:compilefile") let g:compilefile = expand("%") endif execute "!perl -wc -Ilib " . g:compilefile cfile endfunction nmap ,t :call Prove (0) nmap ,T :call Prove (1) nmap ,v :call Compile () nmap ,w :let g:testfile = expand("%"):echo "testfile is now" g:testfile nmap ,W :unlet g:testfile:echo "testfile undefined; will run all tests" " based on compiler/perl.vim by Christian J. Robinson " added formats for test failures set errorformat= \%-G%.%#had\ compilation\ errors., \%-G%.%#syntax\ OK, \%+Anot\ ok\%.%#-\ %m, \%C%.%#\(%f\ at\ line\ %l\), \%m\ at\ %f\ line\ %l., \%+A%.%#\ at\ %f\ line\ %l\\,%.%#, \%+C%.%# " FIXME make this more local. Needed for redirection syntax which isn't csh compatible set sh=/bin/sh " Just more convenient when shelling out a lot. set autowrite