[英]Keyboard shortcut for R assignment operator (<-) in VSCode in editor and terminal
How would I add a keyboard shortcut for the basic assignment operator ( <-
) that works both in the editor AND the terminal?如何为在编辑器和终端中都可以使用的基本赋值运算符(
<-
) 添加键盘快捷键?
Getting it to work in the editor is straightforward (content goes into keybindings.json
):让它在编辑器中工作很简单(内容进入
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": " <- "}
}
But I'm struggling with understanding what the when
clause would need to look like for the terminal.但我正在努力理解终端的
when
子句需要是什么样的。
Things I tried based on the official doc on when clauses :我根据有关 when 子句的官方文档尝试的事情:
terminalFocus
terminalFocus
{
"key": "alt+-",
"command": "type",
// "when": "editorLangId == r && editorTextFocus || editorLangId == rmd && editorTextFocus || terminalFocus",
"args": {"text": " <- "}
}
{
"key": "alt+-",
"command": "type",
// "when": "editorLangId == r && editorTextFocus || editorLangId == rmd && editorTextFocus || editorLangId == shellscript && terminalFocus",
"args": {"text": " <- "}
}
You can't use the type
command to write to the terminal.您不能使用
type
命令写入终端。 Try this instead:试试这个:
{
"key": "alt+-", // or whatever keybinding you want
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": " <- "
},
"when": "terminalFocus && !terminalTextSelected"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.