简体   繁体   English

如何将“-”设置为Sublime Text片段选项卡触发器?

[英]How do I setup “--” as a Sublime Text snippet tab trigger?

I am currently working with fortran in Sublime Text and I'm adding some snippets to make the workflow faster. 我目前正在Sublime Text中使用fortran,并且添加了一些片段以使工作流程更快。

Since fortran does not support the ++ or -- operators, I would like to make snippets that will change these operators to the explicit increment and decrement statements. 由于fortran不支持++或-运算符,因此我想制作一些片段,将这些运算符更改为显式的递增和递减语句。

For example 例如

a++

becomes

a = a + 1

and

a--

becomes

a = a - 1

I have successfully implemented the ++ snippet as follows. 我已经成功实现了如下的++代码段。

<snippet>
    <content><![CDATA[ = $TM_CURRENT_WORD + 1]]></content>
    <tabTrigger>++</tabTrigger>
    <description>i = i + 1</description>
    <scope>source.fortran</scope>
</snippet>

However, my implementation of the -- snippet fails to trigger. 但是,我对-片段的实现无法触发。

<snippet>
    <content><![CDATA[ = $TM_CURRENT_WORD - 1]]></content>
    <tabTrigger>--</tabTrigger>
    <description>i = i - 1</description>
    <scope>source.fortran</scope>
</snippet>

Does anyone have any suggestions on how to get the -- snippet to trigger? 是否有人对如何触发-片段有任何建议? Thanks. 谢谢。

Adding a key binding for the 3-key sequence of minus,minus,tab will do the trick: minus,minus,tab的3键序列添加一个键绑定将达到目的:

{ "keys": ["-", "-", "tab"], 
  "command": "insert_snippet", 
  "args": {"name":"Packages/Fortran/MinusMinus.sublime-snippet"}
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM