簡體   English   中英

編輯器和終端中 VSCode 中 R 賦值運算符 (<-) 的鍵盤快捷鍵

[英]Keyboard shortcut for R assignment operator (<-) in VSCode in editor and terminal

如何為在編輯器終端中都可以使用的基本賦值運算符( <- ) 添加鍵盤快捷鍵?

讓它在編輯器中工作很簡單(內容進入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": " <- "}
}

但我正在努力理解終端的when子句需要是什么樣的。

我根據有關 when 子句的官方文檔嘗試的事情:

  • 使用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": " <- "}
}

您不能使用type命令寫入終端。 試試這個:

{
  "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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM