Rap*_*ter 5 keyboard-shortcuts r visual-studio-code
如何为在编辑器和终端中都有效的基本赋值运算符( )添加键盘快捷键?<-
让它在编辑器中工作很简单(内容进入keybindings.json
):
{
"key": "alt+-",
"command": "type",
"when": "editorLangId == r && editorTextFocus || editorLangId == rmd && editorTextFocus",
// if you want using quarto, try this
// "when": "editorLangId =~ /r|rmd|qmd/ && editorTextFocus",
"args": {"text": " <- "}
}
Run Code Online (Sandbox Code Playgroud)
但我很难理解when
终端的条款需要是什么样子。
我根据有关when子句的官方文档尝试过的事情:
terminalFocus
{
"key": "alt+-",
"command": "type",
// "when": "editorLangId == r && editorTextFocus || editorLangId == rmd && editorTextFocus || terminalFocus",
"args": {"text": " <- "}
}
Run Code Online (Sandbox Code Playgroud)
{
"key": "alt+-",
"command": "type",
// "when": "editorLangId == r && editorTextFocus || editorLangId == rmd && editorTextFocus || editorLangId == shellscript && terminalFocus",
"args": {"text": " <- "}
}
Run Code Online (Sandbox Code Playgroud)
您无法使用该type
命令写入终端。试试这个:
{
"key": "alt+-", // or whatever keybinding you want
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": " <- "
},
"when": "terminalFocus && !terminalTextSelected"
}
Run Code Online (Sandbox Code Playgroud)
请参阅将文本发送到终端文档
归档时间: |
|
查看次数: |
1482 次 |
最近记录: |