REditorSupport / REditorSupport/vscode-R

provide rstudio-like keymaps

Open
#551 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request help wanted
Dominant language
TypeScript
Stars
1.2k
Forks
139
Avg merge
2h 46m
Merged PRs (30d)
5

Description

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"
    },

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the existing r.runCommand and workbench.action.tasks.runTask integrations used by the proposed bindings. Compare the RStudio-specific shortcuts and their R/Rmd when conditions, then determine how an optional setting should enable them. Done means the requested R-specific mappings work without replacing native cross-language VS Code shortcuts.

Written by the indexing model from the issue text.

Assessment

Tech stack
r, typescript, vscode
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.