简体   繁体   中英

VS Code when clause context (for keyboard shortcuts) for LaTeX math mode

In VS Code I can define keyboard shortcuts to only work in certain conditions:

https://code.visualstudio.com/api/references/when-clause-contexts

So i can add different variables, eg this keyboard shortcut would only work when writing latex documents and the text is focused:

{
        "key": "alt+.",
        "command": "editor.action.insertSnippet",
        "when": "editorLangId == latex && editorTextFocus",
        "args": {
            "snippet": "\\cdot $0"
        }
    },
}

Is there any clause context (like "editorTextFocus") that would tell me whether I'm in LaTeX math mode or not that comes with any extension or something (I use the LaTeX Workshop extension)? I haven't found anything online. Or can I define something like this myself? If yes, does anyone know a good resource to find out how to do so?

It is possible to use the extension HyperSnips to create more advanced snippets that only trigger in math-mode (also using regex etc.). Tutorial can be found on their Github. So one could theoretically bind a keyboard shortcut to typing some key or something which then gets auto-expanded by the extension.

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