SublimeText / LaTeXTools

LaTeX plugin for Sublime Text
https://latextools.readthedocs.io/
2k stars 362 forks source link

Keybinding for ^ and _ to automate ^{} and _{} not working. #1496

Open shervinsahba opened 3 years ago

shervinsahba commented 3 years ago

Hi, I'm using the keybinding code from the Wiki, and the improvements to ^ and _ don't function for me. Out of those options, only the first three of these work as intended. The latter two do not work.

// Auto-pair escaped curly brackets                               (WORKS)
// Auto-pair escaped braces                                          (WORKS)
// Auto-pair escaped parentheses                                 (WORKS)
// Improve the usage of ^ and _ to create ^{} and _{}     (DOES NOT WORK)
// Use /, / to insert \frac and *, * to insert \cdot              (DOES NOT WORK)

Could someone suggest keybinding code for ^ and _? I'm currently using the provided code.

    // Improve the usage of ^ and _ to create ^{} and _{}
    {
        "keys": ["^", "^"], "command": "insert_snippet", "args": {"contents": "^{${1:$SELECTION}}$0"},
        "context": [
            { "key": "selector", "operator": "equal", "operand": "text.tex.latex meta.environment.math, text.tex.latex string.other.math" }
        ]
    },
    {
        "keys": ["^"], "command": "insert_snippet", "args": {"contents": "^{${1:$SELECTION}}$0"},
        "context": [
            { "key": "selector", "operator": "equal", "operand": "text.tex.latex meta.environment.math, text.tex.latex string.other.math" },
            { "key": "selection_empty", "operator": "equal", "operand": false }
        ]
    },
    {
        "keys": ["_", "_"], "command": "insert_snippet", "args": {"contents": "_{${1:$SELECTION}}$0"},
        "context": [
            { "key": "selector", "operator": "equal", "operand": "text.tex.latex meta.environment.math, text.tex.latex string.other.math" }
        ]
    },
    {
        "keys": ["_"], "command": "insert_snippet", "args": {"contents": "_{${1:$SELECTION}}$0"},
        "context": [
            { "key": "selector", "operator": "equal", "operand": "text.tex.latex meta.environment.math, text.tex.latex string.other.math" },
            { "key": "selection_empty", "operator": "equal", "operand": false }
        ]
    },

Please let me know if you need more details. Thanks.

rafael-copat commented 2 years ago

They are working for me. Have you tried the last two key bindings in a math environment, such as align?