Skip to content

provide rstudio-like keymaps #551

Description

@maxheld83

Describe 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() or R CMD check and not the general-purpose IDE/Editor bindings (i.e. CTRL+1 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"
    },

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions