简体   繁体   English

Sublime Text 3中的条件数学模式选项卡是否可以自动完成?

[英]Is conditional math mode tab autocompletion possible in Sublime Text 3?

I'd like to define, say, a snippet that will 我想定义一个片段,例如

  1. Tab autocomplete with $$ to create a math mode expression if completion occurs outside of math mode, and 如果自动完成功能发生数学模式之外,则使用$$选项卡自动完成以创建数学模式表达式,并且
  2. Autocomplete without the $$ if completion occurs within math mode. 如果数学模式下发生自动完成,则没有 $$自动完成。

For example, I'd like to define a completion for bb such that 例如,我想为bb定义一个bb

1) bb expands to $\\mathbb{ }$ 1) bb扩展为$\\mathbb{ }$

2) $bb$ expands to $\\mathbb{ }$ and not $$\\mathbb{ }$$ . 2) $bb$扩展为$\\mathbb{ }$不是 $$\\mathbb{ }$$

Is this possible? 这可能吗?

Create two files in your Packages/User directory (select Preferences > Browse Packages... and open the User folder) Packages/User目录中创建两个文件(选择Preferences > Browse Packages...并打开User文件夹)

LaTeX.sublime-completions with the content: LaTeX.sublime-completions的内容:

{
    "scope": "text.tex.latex - meta.environment.math",

    "completions": [
        { "trigger": "bb\t\\\\mathbb{...}", "contents": "\\$\\\\mathbb{$1}\\$$0"},
        { "trigger": "bf\t\\\\mathbf{...}", "contents": "\\$\\\\mathbf{$1}\\$$0"}
    ]
}

LaTeX math.sublime-completions with the content: LaTeX math.sublime-completions的内容:

{
    "scope": "text.tex.latex meta.environment.math",

    "completions": [
        { "trigger": "bb\t\\\\mathbb{...}", "contents": "\\\\mathbb{$1}$0"},
        { "trigger": "bf\t\\\\mathbf{...}", "contents": "\\\\mathbf{$1}$0"}
    ]
}

Now you can add other commands in a similar style. 现在,您可以添加其他类似样式的命令。

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

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