2012-02-29 152 views
7

我刚刚开始使用Sublime Text 2,我很喜欢它。但是,我试图设置一个我将始终使用的代码片段。问题是编辑根本没有意识到它。我将它保存在我的Packages/User文件夹中。片段如下:Sublime Text 2代码片段

<snippet> 
    <content><![CDATA[echo "<pre>".print_r(${0:var},true)."</pre>";]]></content> 
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> 
    <tabTrigger>pre</tabTrigger> 
    <!-- Optional: Set a scope to limit where the snippet will trigger --> 
    <scope>source.php</scope> 
    <description>print r with pre tags</description> 
</snippet> 

任何想法我做错了什么?

回答

15

确保它以.sublime-snippet扩展名保存。当范围是php时,你的代码片段只会扩展。所以它必须在php标记中,即使它在php文件中也是如此。

+0

太棒了,就是这样,我没有用扩展名保存它。谢谢。 – jb1785 2012-03-01 12:55:18

0

创建代码段时,请确保在需要时转义$,因为$符号用作指针。