VSCode 自定义宏
VSCode custom macros
目前我正在尝试使用 VSCode,但我不知道如何正确定义宏并将它们绑定到特定的键绑定。
我习惯使用 Sublime text,我定义了一些宏,可以帮助我更快地输入并减少错误
我想获取的宏如下:
- alt+shift+q :键入
\(\)
并将光标设置在中间(在第一个 (
和第二个 [=16 之间) =]).
- alt+shift+s :键入
\[\]
并将光标设置在中间(第一个 [
和第二个 \
).此外,如果可能的话,我希望它也可以使用 latex-workshop.toggleMathPreviewPanel
. 切换数学预览功能
- alt+shift+a :键入以下内容
\begin{align*}
\item
\end{align*}
\item
前面有一个 tab
,它在 \item
之后设置光标
我已经通过如下操作获得了第一个宏
- 正在安装 geddski 的宏包。
- 正在创建以下宏,并将其插入
settings.json
:
"macros": {
"latex_inline_math": [
{
"command": "type",
"args": {
"text": "\(\)"
}
},
"cursorLeft",
"cursorLeft"
],
}
- 通过像这样插入
keybindings.json
将其绑定到键绑定:
{ // to get \(\)
"key": "alt+shift+q",
"command": "macros.latex_inline_math"
},
但我不知道如何获取宏 2. 和 3.
Also, if there is a better way to write the macro that i wrote, please let me know
您可以定义以下 3 个键绑定
{
"key": "shift+alt+q",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": { "snippet": "\([=10=]\)" }
},
{
"key": "shift+alt+s",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": { "snippet": "\[[=10=]\]" }
},
{
"key": "shift+alt+a",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": { "snippet": "\begin{align*}\n\t\item[=10=]\n\end{align*}" }
}
如果您还想要预览,可以使用扩展程序 multi-command
定义这个键绑定
{
"key": "shift+alt+s",
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"latex-workshop.toggleMathPreviewPanel",
{ "command": "editor.action.insertSnippet", "args": { "snippet": "\[[=11=]\]" } }
]
}
}
目前我正在尝试使用 VSCode,但我不知道如何正确定义宏并将它们绑定到特定的键绑定。
我习惯使用 Sublime text,我定义了一些宏,可以帮助我更快地输入并减少错误
我想获取的宏如下:
- alt+shift+q :键入
\(\)
并将光标设置在中间(在第一个(
和第二个 [=16 之间) =]). - alt+shift+s :键入
\[\]
并将光标设置在中间(第一个[
和第二个\
).此外,如果可能的话,我希望它也可以使用latex-workshop.toggleMathPreviewPanel
. 切换数学预览功能
- alt+shift+a :键入以下内容
\begin{align*}
\item
\end{align*}
\item
前面有一个 tab
,它在 \item
我已经通过如下操作获得了第一个宏
- 正在安装 geddski 的宏包。
- 正在创建以下宏,并将其插入
settings.json
:
"macros": {
"latex_inline_math": [
{
"command": "type",
"args": {
"text": "\(\)"
}
},
"cursorLeft",
"cursorLeft"
],
}
- 通过像这样插入
keybindings.json
将其绑定到键绑定:
{ // to get \(\)
"key": "alt+shift+q",
"command": "macros.latex_inline_math"
},
但我不知道如何获取宏 2. 和 3.
Also, if there is a better way to write the macro that i wrote, please let me know
您可以定义以下 3 个键绑定
{
"key": "shift+alt+q",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": { "snippet": "\([=10=]\)" }
},
{
"key": "shift+alt+s",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": { "snippet": "\[[=10=]\]" }
},
{
"key": "shift+alt+a",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": { "snippet": "\begin{align*}\n\t\item[=10=]\n\end{align*}" }
}
如果您还想要预览,可以使用扩展程序 multi-command
定义这个键绑定
{
"key": "shift+alt+s",
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"latex-workshop.toggleMathPreviewPanel",
{ "command": "editor.action.insertSnippet", "args": { "snippet": "\[[=11=]\]" } }
]
}
}