""""""""""""""""""""""""""" " COMPILE, JUMP TO ERROR, and RUN the "CURRENT FILE TO RUN" " CAREFUL : i MUST have exactly this line in my Perl files : " use Vi::QuickFix 'C:/quickfix_errors_tmp.err'; let $ERROR_FILE = "C:/quickfix_errors_tmp.err" map ;r :call MakeWithCopenAndCfileInNewTab() "current file to make must be the current one... let $CURRENT_FILE_TO_RUN = "%" let $PERL_COMPILE = "perl\\ -Ilib\\ -c\\ " function SetMakeprg() exe ":set makeprg=" . $PERL_COMPILE . $CURRENT_FILE_TO_RUN endfunction autocmd FileType perl call SetMakeprg() autocmd FileType perl set errorformat=%f:%l:%m autocmd FileType perl set autowrite "...unless we choose the file that we are reading as the "current file to run" map ;f :call SetActiveFileToRun() function SetActiveFileToRun() let $CURRENT_FILE_TO_RUN=bufname("%") call SetMakeprg() endfunction " print who is the "current file to run" map ;F :call TellAndStop("The \"file to run\" with ;r is " \ . $CURRENT_FILE_TO_RUN \ . "\nUse ;R to run the active buffer file instead" ) "Compile, jump to first error (with QuickFix), and execute if there's no error "From Marc Jessome, by email, 14th July 2012. "I modified the "for e in qflist "if !e.valid "by replacing it with "if len(qflist)>1 " because the elements of my qflist were not valid until i used :cfile function MakeWithCopenAndCfileInNewTab() make let qflist = getqflist() if len(qflist)>1 tabnew copen cfile $ERROR_FILE else exe "!perl\ -Ilib\ " . $CURRENT_FILE_TO_RUN endif endfunction " tells something to the user, and asks to press a button function TellAndStop(text) call inputsave() let name = input(a:text . "\npress Enter...") call inputrestore() endfunction "run the current file, not the "current_file_to_make" map ;R :call MakeTheCurrentFile() function MakeTheCurrentFile() "copy the "current_file_to_make" to a buffer let $BUF=$CURRENT_FILE_TO_RUN "compile+run the current file let $CURRENT_FILE_TO_RUN=bufname('%') call SetMakeprg() call MakeWithCopenAndCfileInNewTab() "retrieve the "current_file_to_make" path (from the buffer) let $CURRENT_FILE_TO_RUN=$BUF call SetMakeprg() endfunction "used for QuickFix to open its window after i compile set switchbuf=useopen " to quit a tab with 2 buffers open map ;qq :q:q " END of : COMPILE, JUMP TO ERROR, and RUN the "CURRENT FILE TO RUN " """"""""""""""""""""