Vim下一键运行python代码,,根据系统将下面代码复
Vim下一键运行python代码,,根据系统将下面代码复
根据系统将下面代码复制到vim配置文件vimrc中,即可在vim中一键【F5】运行.py文件。
Windows下的gvim
"一键运行代码function CheckPythonSyntax() let mp = &makeprg let ef = &errorformat let exeFile = expand("%:t") setlocal makeprg=python\ -u set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m silent make % copen " set efm 是设置quickfix的errorformat,以便vim识别 " makeprg 是vim内置的编译命令,可以通过更改来实现编译对应类型文件。具体可参考vim官方说明文件。" copen是打开quickfix,n用来设置quichfix窗口大小,如 cope5。在错误描述上回车,可以直接跳转到错误行。 let &makeprg = mp let &errorformat = ef endfunction"一个是普通模式下,一个是插入模式下au filetype python map <f5> :w <cr> :call CheckPythonSyntax() <cr>au filetype python imap <f5> <esc> :w <cr> :call CheckPythonSyntax() <cr></cr></cr></esc></f5></cr></cr></f5>
Linux下的vim
"一键运行代码map <F5> :call CompileRunGcc()<CR> func! CompileRunGcc() exec "w"if &filetype == 'c' exec "!g++ % -o %<" exec "!time ./%<"elseif &filetype == 'cpp' exec "!g++ % -o %<" exec "!time ./%<"elseif &filetype == 'java' exec "!javac %" exec "!time java %<"elseif &filetype == 'sh' :!time bash %elseif &filetype == 'python' exec "!time python %"elseif &filetype == 'html' exec "!firefox % &"elseif &filetype == 'go' " exec "!go build %<" exec "!time go run %"elseif &filetype == 'mkd' exec "!~/.vim/markdown.pl % > %.html &" exec "!firefox %.html &"endif endfunc
Vim下一键运行python代码
相关内容
- Python:简单的文件备份脚本,,文件备份脚本,实现了
- Python简单爬虫,,简单抓取网页的代码i
- python 运行sum函数的使用,,sum(iterab
- Python爬虫--- 1.1请求库的安装与使用,,原文链接:http
- Robot Framework+AutoItLibrary使用,,目的:用Robot
- 解决:main.py: error: unrecognized arguments: --html,,怎么运行
- python提取数字对比任意相同,,import rep
- python之random模块,,# 关于random
- Python 进制转换、位运算,,一、进制转换编程用十
- Cython保护python代码,,注:.pyc也有一定
评论关闭