简体   繁体   中英

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.

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.

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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