Psst.. new poll here.
[email protected] web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as Vim Script by 123 ( 12 years ago )
autocmd BufRead,BufEnter *.py nmap <silent><F5> <ESC> :call CheckPythonSyntax()<CR>
autocmd BufRead,BufEnter *.py imap <silent><F5> <ESC> :call CheckPythonSyntax()<CR>
function CheckPythonSyntax()
" Write the current buffer to a temporary file, check the syntax and
" if no syntax errors are found, write the file
let curfile = bufname("%")
let tmpfile = tempname()
silent execute "write! ".tmpfile
let output = system("python -c \"__import__('py_compile').compile(r'".tmpfile."')\" 2>&1")
if output != ''
" Make sure the output specifies the correct filename
let output = substitute(output, fnameescape(tmpfile), fnameescape(curfile), "g")
echo output
else
write
endif
" Delete the temporary file when done
call delete(tmpfile)
endfunction
Revise this Paste