run.vim 631 B

1234567891011121314151617181920
  1. " DESC: Save file if it modified and run python code
  2. fun! pymode#run#Run(line1, line2) "{{{
  3. if &modifiable && &modified | write | endif
  4. py import StringIO
  5. py sys.stdout, _ = StringIO.StringIO(), sys.stdout
  6. call pymode#WideMessage("Code running.")
  7. try
  8. py execfile(vim.eval('expand("%s:p")'))
  9. py sys.stdout, out = _, sys.stdout.getvalue()
  10. call pymode#TempBuffer()
  11. py vim.current.buffer.append(out.split('\n'), 0)
  12. wincmd p
  13. call pymode#WideMessage("")
  14. catch /.*/
  15. echohl Error | echo "Run-time error." | echohl none
  16. endtry
  17. endfunction "}}}