Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 855
user1056750 Avatar asked Feb 02 '26 06:02

user1056750


1 Answers

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"}
}
like image 106
Craig Jones Avatar answered Feb 05 '26 05:02

Craig Jones



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!