Skip to content

Instantly share code, notes, and snippets.

@dikiprawisuda
Forked from stephenturner/keybindings.json
Last active June 25, 2023 10:48
Show Gist options
  • Save dikiprawisuda/730df41e21fe8847121fd7b67f5b0e7c to your computer and use it in GitHub Desktop.
Save dikiprawisuda/730df41e21fe8847121fd7b67f5b0e7c to your computer and use it in GitHub Desktop.
VSCode keybindings to replicate my most commonly used RStudio shortcuts (Mac) and some additions
// Place your key bindings in this file to override the defaults
[
// keybindings for R scripts, Rmarkdown, Quarto, and R terminal (radian included)
{
"key": "Ctrl+Shift+m",
"command": "type",
"args": {
"text": " %>% "
},
"when": "editorTextFocus && (editorLangId == r || editorLangId == rmd || editorLangId == quarto)"
},
{
"key": "Alt+-",
"command": "type",
"args": {
"text": " <- "
},
"when": "editorTextFocus && (editorLangId == r || editorLangId == rmd || editorLangId == quarto)"
},
{
"key": "ctrl+l",
"command": "workbench.action.terminal.clear",
"when": "terminalFocus"
},
// RStudio: Copy lines up/down with alt+cmd+up/down
{
"key": "alt+cmd+down",
"command": "editor.action.copyLinesDownAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+alt+down",
"command": "-editor.action.copyLinesDownAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "alt+cmd+up",
"command": "editor.action.copyLinesUpAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+alt+up",
"command": "-editor.action.copyLinesUpAction",
"when": "editorTextFocus && !editorReadonly"
},
// RStudio: Insert cursors above and below with ctrl-alt+up/down
{
"key": "ctrl+alt+down",
"command": "editor.action.insertCursorBelow",
"when": "editorTextFocus"
},
{
"key": "alt+cmd+down",
"command": "-editor.action.insertCursorBelow",
"when": "editorTextFocus"
},
{
"key": "ctrl+alt+up",
"command": "editor.action.insertCursorAbove",
"when": "editorTextFocus"
},
{
"key": "alt+cmd+up",
"command": "-editor.action.insertCursorAbove",
"when": "editorTextFocus"
},
// RStudio: Delete lines cmd-d
{
"key": "cmd+d",
"command": "editor.action.deleteLines",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+cmd+k",
"command": "-editor.action.deleteLines",
"when": "editorTextFocus && !editorReadonly"
},
// The above remapping destroyed the find next shortcut.
// Replace it with alt+d and shift-alt+d to get them all
{
"key": "alt+d",
"command": "editor.action.addSelectionToNextFindMatch",
"when": "editorFocus"
},
{
"key": "cmd+d",
"command": "-editor.action.addSelectionToNextFindMatch",
"when": "editorFocus"
},
{
"key": "shift+alt+d",
"command": "editor.action.selectHighlights",
"when": "editorFocus"
},
{
"key": "shift+cmd+l",
"command": "-editor.action.selectHighlights",
"when": "editorFocus"
},
// Run current line in a terminal
{
"key": "cmd+enter",
"command": "workbench.action.terminal.runSelectedText"
},
// Make tab switching more like a web browser
// Use ctrl+alt(+shift)+tab to replace the default behavior.
{
"key": "ctrl+tab",
"command": "workbench.action.nextEditor"
},
{
"key": "ctrl+shift+tab",
"command": "workbench.action.previousEditor"
},
{
"key": "ctrl+alt+tab",
"command": "workbench.action.openNextRecentlyUsedEditorInGroup"
},
{
"key": "ctrl+tab",
"command": "-workbench.action.openNextRecentlyUsedEditorInGroup"
},
{
"key": "ctrl+shift+alt+tab",
"command": "workbench.action.openPreviousRecentlyUsedEditorInGroup"
},
{
"key": "ctrl+shift+tab",
"command": "-workbench.action.openPreviousRecentlyUsedEditorInGroup"
},
{
"key": "ctrl+alt+tab",
"command": "workbench.action.quickOpenNavigateNext",
"when": "inQuickOpen"
},
{
"key": "ctrl+tab",
"command": "-workbench.action.quickOpenNavigateNext",
"when": "inQuickOpen"
},
{
"key": "ctrl+shift+alt+tab",
"command": "workbench.action.quickOpenNavigatePrevious",
"when": "inQuickOpen"
},
{
"key": "ctrl+shift+tab",
"command": "-workbench.action.quickOpenNavigatePrevious",
"when": "inQuickOpen"
}
// OTHER KEYBINDINGS
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment