VIM实现F5运行php/perl/python/c/java/erlang
发布时间:2020-12-15 07:09:47 所属栏目:安全 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 function RunThisScript() let file_name = expand("%:p") let file_ext = expand("%:e") let file_cmd = "" "python 直接调用 if file_ext == "py" l
以下代码由PHP站长网 52php.cn收集自互联网 现在PHP站长网小编把它分享给大家,仅供参考 function RunThisScript() let file_name = expand("%:p") let file_ext = expand("%:e") let file_cmd = "" "python 直接调用 if file_ext == "py" let file_cmd = '/usr/bin/python' let file_args = ' ' . file_name "c 需要提取第一行的编译参数 "如,当需要引入第三方库(以mysql为例)时,则在第一行添加: //-lmysqlclient -L/usr/local/mysql/include "文件中则可直接 #include <mysql/mysql.h> elseif file_ext == "c" let file_first_line = getline(1) let file_arg = "" if strpart(file_first_line,2) == '//' let file_arg = strpart(file_first_line,2) "提取参数 endif let file_output_file = strpart(file_name,strridx(file_name,'.c')) let file_args = ' -o '. file_output_file .' '. file_name . ' '. file_arg .' && '. file_output_file "将参数附加到编译命令之后 let file_cmd = '/usr/bin/cc' "php 直接调用 elseif file_ext == "php" let file_cmd = "/usr/local/php/bin/php" "php执行路径 let file_args = ' -f '. file_name "perl 直接调用 elseif file_ext == "perl" || file_ext == "pl" let file_cmd = "/usr/bin/perl" let file_args = " ". file_name "erlang 默认调用 main 函数,可以确保 escript 和 noshell/shell 执行时一致 elseif file_ext == "erl" let file_output_file = strpart(expand("%"),stridx(expand("%"),".erl")) let file_cmd = "/usr/bin/erlc" let file_args = file_output_file .".". file_ext ." ; /usr/bin/erl -noshell -s ". file_output_file . " main -s init stop" "java 先调用 javac,再调用java elseif file_ext == "java" let file_output_file = strpart(expand("%"),".java")) let file_cmd = 'javac' let file_args = file_name ." && java ". file_output_file else echo "错误: 没有任何编译器匹配此文件类型,请确认您的文件扩展名!" endif if file_cmd != "" if ! executable(file_cmd) echo file_cmd echo "The executable file to compile ". file_ext . " type files." else let cmd = "! ". file_cmd . ' ' . file_args "echo "执行命令: ". cmd exec cmd endif endif endfunction 以上内容由PHP站长网【52php.cn】收集整理供大家参考研究 如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |