provide rstudio-like keymaps
See original GitHub issueDescribe the solution you’d like
I’d love it if there was a way to quickly get the key bindings that I (and I suspect many others) have muscle-memoried from RStudio.
Caveats:
- This should only cover R-specific keybindings, such as for
devtools::load_all()
orR CMD check
and not the general-purpose IDE/Editor bindings (i.e. <kbd>CTRL</kbd>+<kbd>1</kbd> for “move to source editor”. VSCode is a different beast and has a completely different design, so it doesn’t make sense for it to behave like RStudio all around. As a heuristic, only those keybindings should be enabled which only make sense inside R projects. If there’s already a native, cross-language VSCode shortcut, that should take precedence. - Consequently, this should only trigger when
"when": "editorLangId == r || editorLangId == rmd && editorTextFocus"
. - Some default VSCode keybindings would have to be overwritten (see below).
- The whole thing could maybe be enabled as an option in the setting.
Here’s what I have so far (using tasks as per #59):
{
"description": "Insert <-",
"key": "alt+-",
"command": "type",
"when": "editorLangId == r || editorLangId == rmd && editorTextFocus",
"args": {
"text": "<- "
}
},
{
"description": "Insert %>%",
"key": "ctrl+shift+m",
"command": "type",
"when": "editorLangId == r || editorLangId == rmd && editorTextFocus",
"args": {
"text": "%>% "
}
},
{
// "description": "Disable (overloaded with above)",
"key": "ctrl+shift+m",
"when": "editorLangId == r || editorLangId == rmd && editorTextFocus",
"command": "-workbench.actions.view.problems"
},
{
"description": "Load all",
"key": "cmd+shift+l",
"command": "r.runCommand",
"when": "editorLangId == r || editorLangId == rmd",
"args": "devtools::load_all()"
},
{
"description": "Test",
"key": "cmd+shift+t",
"command": "workbench.action.tasks.runTask",
"when": "editorLangId == r || editorLangId == rmd",
"args": "Test"
},
{
"description": "Document",
"key": "cmd+shift+d",
"command": "workbench.action.tasks.runTask",
"when": "editorLangId == r || editorLangId == rmd",
"args": "Document"
},
{
"description": "Check",
"key": "cmd+shift+e",
"command": "workbench.action.tasks.runTask",
"when": "editorLangId == r || editorLangId == rmd",
"args": "Check"
},
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Provide R package-related tasks · Issue #59 - GitHub
I structure most of my projects as packages and use a workflow based around devtools::load_all() and devtools::test() , but I've never submitted ...
Read more >VS Code tips — Keymaps - YouTube
Today's VS Code basics: keymapsKeymap extensions change VS Code's keyboard shortcuts to emulate those from other popular editors such as ...
Read more >init.vim · main · Fabian Mundt / dotfiles - GitLab
Allow backspace beyond insertion point ... For any plugins that use this, make their keymappings use comma ... RStudio like sections.
Read more >Unanswered 'shortcut' Questions - Page 11 - Stack Overflow
I try to create a shortcut with setup wizard but it doesn't give the path of the ... Do we have something in...
Read more >Untitled
14 hours ago · Atom or Rstudio like IDE alternative for julia language. ... Configuration API; Keymaps In-Depth; Scoped Settings, Scopes and Scope ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I found this issue because I fell for an unexpected key mapping collision: in RStudio, <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>S</kbd> runs the source, while that combination in VS Code (and many other tools, compare https://defkey.com/what-means/ctrl-shift-s) is usually used for “File - Save As”. So instead of re-saving my file, I accidentally ran some R code in VS Code due to https://github.com/Ikuyadeu/vscode-R/blob/abd2392d7ef02ea5151b26004368fdedfcc979f4/package.json#L651-L656
In general, I am not sure it is beneficial to emulate RStudio behavior at all. RStudio is only for people working (mostly) with R. VS Code is not only for people who mostly use R, but people also use JavaScript, Python, etc. - often several languages across the same project. So I think I would put more focus on being consistent within the VS Code environment rather than compatibility with RStudio. Please consider that if and when revising any keyboard shortcuts (including <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>S</kbd>). It’s easy for me to unmap*, but new users will always fall for that.
*How? Put this in your
keybindings.json
:You could also add a default-false setting such as
config.latex-workshop.bind.altKeymap.enabled
in LaTeX Workshop and scope two sets of key bindings to that. That’s how they implement it: https://github.com/James-Yu/LaTeX-Workshop/blob/f6016f6dd15992894935545e25ef1a6a2b6ef411/package.json#L481-L577I think this is a great idea in general, and it would allow maintaining one (default) set of key bindings with maximum compatibility to VS Code, and another for RStudio users that can be enabled using a single setting.