设为首页 收藏本站
查看: 942|回复: 0

[经验分享] Vim的snipMate插件 php代码自动补全

[复制链接]
发表于 2017-4-9 07:21:56 | 显示全部楼层 |阅读模式
Vim的snipMate插件 

介绍 
终于发现了一个插件,对于Vim下代码块的自动补全支持的很好。给大家推荐snipMate。 

snipMate可以帮助您在vim上实现类似Textmate的功能,自动代码块的能力非常强大,而且代码块是可定制的。我们只需编辑~/.vim/snippets/目录下的*.snippets文件就可以根据自己的要求自动产生代码。 

使用 
下载snipMate,解压到你的Vim目录。 
完成之后,新建一个测试文件snipMateTest.php准备测试 

vim snipMateTest.php 

然后按照下面的方式开始测试snipMate: 
输入for,再按tab键 
输入foreach,再按tab键 
输入class,再按tab键 
输入fun,再按tab键 
效果如图 

DSC0000.png  

http://www.ccvita.com/481.html 

snipMate插件php自动补全配置文件: 

Java代码   DSC0001.png


  • snippet php  
  •     <?php  
  •     ${1}  
  • snippet ec  
  •     echo "${1:string}"${2};  
  • snippet inc  
  •     include '${1:file}';${2}  
  • snippet inc1  
  •     include_once '${1:file}';${2}  
  • snippet req  
  •     require '${1:file}';${2}  
  • snippet req1  
  •     require_once '${1:file}';${2}  
  • # $GLOBALS['...']  
  • snippet globals  
  •     $GLOBALS['${1:variable}']${2: = }${3:something}${4:;}${5}  
  • snippet $_ COOKIE['...']  
  •     $_COOKIE['${1:variable}']${2}  
  • snippet $_ ENV['...']  
  •     $_ENV['${1:variable}']${2}  
  • snippet $_ FILES['...']  
  •     $_FILES['${1:variable}']${2}  
  • snippet $_ Get['...']  
  •     $_GET['${1:variable}']${2}  
  • snippet $_ POST['...']  
  •     $_POST['${1:variable}']${2}  
  • snippet $_ REQUEST['...']  
  •     $_REQUEST['${1:variable}']${2}  
  • snippet $_ SERVER['...']  
  •     $_SERVER['${1:variable}']${2}  
  • snippet $_ SESSION['...']  
  •     $_SESSION['${1:variable}']${2}  
  • # Start Docblock  
  • snippet /* 
  •     /** 
  •      * ${1} 
  •      **/  
  • # Class - post doc  
  • snippet doc_cp  
  •     /** 
  •      * ${1:undocumented class} 
  •      * 
  •      * @package ${2:default} 
  •      * @author ${3:`g:snips_author`} 
  •     **/${4}  
  • # Class Variable - post doc  
  • snippet doc_vp  
  •     /** 
  •      * ${1:undocumented class variable} 
  •      * 
  •      * @var ${2:string} 
  •      **/${3}  
  • # Class Variable  
  • snippet doc_v  
  •     /** 
  •      * ${3:undocumented class variable} 
  •      * 
  •      * @var ${4:string} 
  •      **/  
  •     ${1:var} $${2};${5}  
  • # Class  
  • snippet doc_c  
  •     /** 
  •      * ${3:undocumented class} 
  •      * 
  •      * @packaged ${4:default} 
  •      * @author ${5:`g:snips_author`} 
  •      **/  
  •     ${1:}class ${2:}  
  •     {${6}  
  •     } // END $1class $2  
  • # Constant Definition - post doc  
  • snippet doc_dp  
  •     /** 
  •      * ${1:undocumented constant} 
  •      **/${2}  
  • # Constant Definition  
  • snippet doc_d  
  •     /** 
  •      * ${3:undocumented constant} 
  •      **/  
  •     define(${1}, ${2});${4}  
  • # Function - post doc  
  • snippet doc_fp  
  •     /** 
  •      * ${1:undocumented function} 
  •      * 
  •      * @return ${2:void} 
  •      * @author ${3:`g:snips_author`} 
  •      **/${4}  
  • # Function signature  
  • snippet doc_s  
  •     /** 
  •      * ${4:undocumented function} 
  •      * 
  •      * @return ${5:void} 
  •      * @author ${6:`g:snips_author`} 
  •      **/  
  •     ${1}function ${2}(${3});${7}  
  • # Function  
  • snippet doc_f  
  •     /** 
  •      * ${4:undocumented function} 
  •      * 
  •      * @return ${5:void} 
  •      * @author ${6:`g:snips_author`} 
  •      **/  
  •     ${1}function ${2}(${3})  
  •     {${7}  
  •     }  
  • # Header  
  • snippet doc_h  
  •     /** 
  •      * ${1} 
  •      * 
  •      * @author ${2:`g:snips_author`} 
  •      * @version ${3:$Id$} 
  •      * @copyright ${4:$2}, `strftime('%d %B, %Y')` 
  •      * @package ${5:default} 
  •      **/  
  •       
  •     /** 
  •      * Define DocBlock 
  •      *//  
  • # Interface  
  • snippet doc_i  
  •     /** 
  •      * ${2:undocumented class} 
  •      * 
  •      * @package ${3:default} 
  •      * @author ${4:`g:snips_author`} 
  •      **/  
  •     interface ${1:}  
  •     {${5}  
  •     } // END interface $1  
  • class ...  
  • snippet class  
  •     /** 
  •      * ${1} 
  •      **/  
  •     class ${2:ClassName}  
  •     {  
  •         ${3}  
  •         function ${4:__construct}(${5:argument})  
  •         {  
  •             ${6:// code...}  
  •         }  
  •     }  
  • # define(...)  
  • snippet def  
  •     define('${1}'${2});${3}  
  • # defined(...)  
  • snippet def?  
  •     ${1}defined('${2}')${3}  
  • snippet wh  
  •     while (${1:/* condition */}) {  
  •         ${2:// code...}  
  •     }  
  • do ... while  
  • snippet do  
  •     do {  
  •         ${2:// code... }  
  •     } while (${1:/* condition */});  
  • snippet if  
  •     if (${1:/* condition */}) {  
  •         ${2:// code...}  
  •     }  
  • snippet ife  
  •     if (${1:/* condition */}) {  
  •         ${2:// code...}  
  •     } else {  
  •         ${3:// code...}  
  •     }  
  •     ${4}  
  • snippet else  
  •     else {  
  •         ${1:// code...}  
  •     }  
  • snippet elseif  
  •     elseif (${1:/* condition */}) {  
  •         ${2:// code...}  
  •     }  
  • # Tertiary conditional  
  • snippet t  
  •     $${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5}  
  • snippet switch  
  •     switch ($${1:variable}) {  
  •         case '${2:value}':  
  •             ${3:// code...}  
  •             break;  
  •         ${5}  
  •         default:  
  •             ${4:// code...}  
  •             break;  
  •     }  
  • snippet case  
  •     case '${1:value}':  
  •         ${2:// code...}  
  •         break;${3}  
  • snippet for  
  •     for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {  
  •         ${4// code...}  
  •     }  
  • snippet foreach  
  •     foreach ($${1:variable} as $${2:key}) {  
  •         ${3:// code...}  
  •     }  
  • snippet fun  
  •     ${1:public }function ${2:FunctionName}(${3})  
  •     {  
  •         ${4:// code...}  
  •     }  
  • # $... = array (...)  
  • snippet array  
  •     $${1:arrayName} = array('${2}' => ${3});${4}  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-362186-1-1.html 上篇帖子: 【代码】PHP 生成GIF动画实现动态图片验证码 下篇帖子: PHP类实例教程(十一):类中this关键字
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表