分配双下划线 - Sublime和R.

时间:2014-08-06 14:31:28

标签: r sublimetext2 sublimetext

在Vim中,编辑R脚​​本时,我已将双下划线__映射到赋值运算符<-。我怎样才能在Sublime Text 2中做同样的事情?

2 个答案:

答案 0 :(得分:1)

你必须使用Snippets。在Sublime中点击工具&gt;新片段。

<snippet>
<content><![CDATA[
<-
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>__</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.r</scope>
</snippet>

将其保存为类似PHP.sublime-snippet的内容。现在,无论何时键入“__”和制表符,它都会更改为&lt; - 。

答案 1 :(得分:0)

Preferences > Key Bindings下添加

   { "keys": ["_", "_"], 
     "command": "insert", 
     "args": {"characters": " <- "},
     "context": {"key": "selector", "operator": "equal", "operand": "source.r" }
   } 

这会自动将__转换为<-个文件中的.R,而无需标记为Tab