简体   繁体   English

LaTeX 数学模式的 VS Code when 子句上下文(用于键盘快捷键)

[英]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:在 VS Code 中,我可以定义键盘快捷键以仅在特定条件下工作:

https://code.visualstudio.com/api/references/when-clause-contexts 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:所以我可以添加不同的变量,例如,此键盘快捷键仅在编写 latex 文档且文本被聚焦时才有效:

{
        "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)?是否有任何子句上下文(如“editorTextFocus”)可以告诉我我是否处于 LaTeX 数学模式或任何扩展或其他东西(我使用 LaTeX Workshop 扩展)? 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.).可以使用扩展 HyperSnips 创建更高级的片段,这些片段仅在数学模式下触发(也使用正则表达式等)。 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.可以在他们的 Github 上找到教程。因此理论上可以将键盘快捷键绑定到键入某个键或其他内容,然后由扩展程序自动扩展。

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

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