自己编写sublime text 2的snippet扩展包

我用codeigniter框架,view中经常会用到“<?=xxxx?>”嵌入PHP代码,一个字符一个字符的敲很麻烦,所以自己增加了一个snippet扩展来解决这个问题。步骤如下:

1. 菜单:tools->new snippet,弹出一个snippet模板。
2. content部分内容:

<![CDATA[
<?=${1:/*your code*/}?>
]]>

3. tabTrigger自己定义即可,我定义的是“sphp”,是simple php的意思。
4. scope很重要,表示这个snippet在什么文件或什么内容下有效。填写“text.html – source”。
5. 将文件保存在”packages/User”目录下,以sublime-snippet为扩展名。
6. 重启sublime text 2,该snippet即可使用了。

文件完整的内容如下:

<snippet>
	<content><![CDATA[
<?=${1:/*your code*/}?>
]]></content>
	<tabTrigger>sphp</tabTrigger>
	<scope>text.html - source</scope>
</snippet>

Leave a Comment

Formatting Your Comment

The following XHTML tags are available for use:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

URLs are automatically converted to hyperlinks.