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):
{
"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.
Things I tried based on the official doc on when clauses:
- using
terminalFocus
{
"key": "alt+-",
"command": "type",
// "when": "editorLangId == r && editorTextFocus || editorLangId == rmd && editorTextFocus || terminalFocus",
"args": {"text": " <- "}
}
- additional explicit language ID based on official doc
{
"key": "alt+-",
"command": "type",
// "when": "editorLangId == r && editorTextFocus || editorLangId == rmd && editorTextFocus || editorLangId == shellscript && terminalFocus",
"args": {"text": " <- "}
}