nee*_*dle 5 macros latex keyboard-shortcuts visual-studio-code
我目前正在尝试使用 VSCode,但我不知道如何正确定义宏并将它们绑定到特定的按键绑定。
我习惯使用 Sublime text,并且我定义了一些宏,可以帮助我更快地打字并减少错误
我想要获得的宏如下:
\(\)
并将光标设置在中间(第一个(
和第二个之间\
)。\[\]
并将光标设置在中间(第一个[
和第二个之间\
)。此外,如果可能的话,我希望它也可以使用 切换数学预览功能latex-workshop.toggleMathPreviewPanel
。\begin{align*}
\item
\end{align*}
Run Code Online (Sandbox Code Playgroud)
\item
前面有 a ,tab
它将光标设置在\item
我已经通过执行以下操作成功获得了第一个宏
settings.json
:"macros": {
"latex_inline_math": [
{
"command": "type",
"args": {
"text": "\\(\\)"
}
},
"cursorLeft",
"cursorLeft"
],
}
Run Code Online (Sandbox Code Playgroud)
keybindings.json
:{ // to get \(\)
"key": "alt+shift+q",
"command": "macros.latex_inline_math"
},
Run Code Online (Sandbox Code Playgroud)
但我不知道如何获取宏 2. 和 3.
另外,如果有更好的方法来编写我编写的宏,请告诉我
您可以定义以下 3 个键绑定
{
"key": "shift+alt+q",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": { "snippet": "\\($0\\)" }
},
{
"key": "shift+alt+s",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": { "snippet": "\\[$0\\]" }
},
{
"key": "shift+alt+a",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": { "snippet": "\\begin{align*}\n\t\\item$0\n\\end{align*}" }
}
Run Code Online (Sandbox Code Playgroud)
如果您还想要预览,可以使用扩展多重命令
定义此键绑定
{
"key": "shift+alt+s",
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"latex-workshop.toggleMathPreviewPanel",
{ "command": "editor.action.insertSnippet", "args": { "snippet": "\\[$0\\]" } }
]
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6007 次 |
最近记录: |