给sublime设置代码片段,快捷键,加快操作,pre快捷键

Tools>New Snippets

代码片段:

<snippet>
    <content><![CDATA[
echo "
";
	print_r(\$${1:arr});
echo "
"
; exit; ]]></content> <tabTrigger>pre</tabTrigger> <scope>source.php</scope> <description>pre …</description> </snippet>

保存地址:

C:\Program Files\Sublime Text 3\Data\Packages\sublime-snippet\

默认地址:
sublime 3207

C:\Users\user\AppData\Roaming\Sublime Text 3\Packages\User

然后,在你写php代码的时候,只需要敲一下pre就可以出来

echo "
";
	print_r($arr);
echo "
"
; exit;

原样输出数组,是不是很方便???赶紧试试吧!

添加快速返回jso代码,注意$符号需要转义!

<snippet>
	<content><![CDATA[
return \$this->outPutJson('',201,'${1:参数错误!}');
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<!-- Hello, ${1:this} is a ${2:snippet}. -->
	<tabTrigger>ret</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<scope>source.php</scope>
	<description>return json …</description>
</snippet>

${1:xxx} 表示光标选中的部分;
${2:snippet} 表示按tab键,光标切换的位置.
CDATA里面的内容就是代码啦
scope就表示使用这个快捷键的文件类型
description表示这个快捷键的描述
tabTrigger表示触发这段代码的快捷键

参考文章:http://blog.csdn.net/admin_yi/article/details/53671726
http://sublimetext.info/docs/en/extensibility/snippets.html

https://www.jianshu.com/p/356bd7b2ea8e

文件类型:
https://gist.github.com/J2TeaM/a54bafb082f90c0f20c9
可使用的变量:
https://sublime-text-unofficial-documentation.readthedocs.io/en/latest/extensibility/snippets.html
说明:
https://www.freecodecamp.org/news/a-guide-to-preserving-your-wrists-with-sublime-text-snippets-7541662a53f2/

你可能感兴趣的:(php)