Skip to content

Instantly share code, notes, and snippets.

@emelens
Last active Jun 21, 2019
Embed
What would you like to do?
Calva shortcuts for visual studio code

In VSCode, the default key binding for ctrl+, points to the settings menu. The number of times people access settings windows is far more less than the number of times s-expressions are executed. I modified calva key bindings to use ctrl+, (ctrl+oem_comma) instead of ctrl+alt+c. I also remapped the workbench settings keybinding to ctrl+, g so that it is still accessible. I left the Paredit settings unmodified. However, they are included in the below gist for reference. All the when clause of "when": "editorTextFocus && editorLangId == 'clojure'" so that their scope is limited to clojure only.

// Place your key bindings in this file to override the defaults
[
 { "key": "ctrl+oem_comma g",        "command": "workbench.action.openSettings" , "when": "editorTextFocus && editorLangId == 'clojure'"},
   { "key": "ctrl+oem_comma j", "command": "calva.jackIn" , "when": "editorTextFocus && editorLangId == 'clojure'"},
{ "key": "ctrl+oem_comma c", "command": "calva.connect", "when": "editorTextFocus && editorLangId == 'clojure'" },
{ "key": "ctrl+oem_comma t", "command": "calva.toggleCLJCSession", "when": "editorTextFocus && editorLangId == 'clojure'" },
{ "key": "ctrl+oem_comma r", "command": "calva.recreateCljsRepl", "when": "editorTextFocus && editorLangId == 'clojure'" },
{ "key": "ctrl+oem_comma s",          "command": "calva.selectCurrentForm", "when": "editorTextFocus && editorLangId == 'clojure'" },
{ "key": "escape",                "command": "calva.clearInlineResults",
                                     "when": "editorTextFocus && !editorHasMultipleSelections && !editorReadOnly && !hasOtherSuggestions && !suggestWidgetVisible && editorLangId == 'clojure'" },
{ "key": "ctrl+oem_comma e",          "command": "calva.evaluateSelection" , "when": "editorTextFocus && editorLangId == 'clojure'"},
{ "key": "ctrl+oem_comma space",      "command": "calva.evaluateCurrentTopLevelForm" , "when": "editorTextFocus && editorLangId == 'clojure'"},
{ "key": "ctrl+oem_comma p",          "command": "calva.evaluateSelectionPrettyPrint" , "when": "editorTextFocus && editorLangId == 'clojure'"},
{ "key": "ctrl+oem_comma ctrl+p",     "command": "calva.evaluateCurrentTopLevelFormPrettyPrint" , "when": "editorTextFocus && editorLangId == 'clojure'"},
{ "key": "ctrl+oem_comma r",          "command": "calva.evaluateSelectionReplace" , "when": "editorTextFocus && editorLangId == 'clojure'"},
{ "key": "ctrl+oem_comma c",          "command": "calva.evaluateSelectionAsComment" , "when": "editorTextFocus && editorLangId == 'clojure'"},
{ "key": "ctrl+oem_comma ctrl+c",     "command": "calva.copyLastResults" , "when": "editorTextFocus && editorLangId == 'clojure'"},
{ "key": "ctrl+oem_comma enter",      "command": "calva.loadFile" , "when": "editorTextFocus && editorLangId == 'clojure'"},
{ "key": "ctrl+oem_comma ctrl+u",     "command": "calva.requireREPLUtilities" , "when": "editorTextFocus && editorLangId == 'clojure'"},
{ "key": "ctrl+oem_comma l",          "command": "calva.lintFile" , "when": "editorTextFocus && editorLangId == 'clojure'"},
{ "key": "ctrl+oem_comma t",          "command": "calva.runNamespaceTests" , "when": "editorTextFocus && editorLangId == 'clojure'"},
{ "key": "ctrl+oem_comma shift+t",    "command": "calva.runAllTests" , "when": "editorTextFocus && editorLangId == 'clojure'"},
{ "key": "ctrl+oem_comma ctrl+t",     "command": "calva.rerunTests" , "when": "editorTextFocus && editorLangId == 'clojure'"},
{ "key": "ctrl+oem_comma ctrl+alt+n", "command": "calva.loadNamespace" , "when": "editorTextFocus && editorLangId == 'clojure'"},
{ "key": "ctrl+oem_comma alt+n",      "command": "calva.setREPLNamespace" , "when": "editorTextFocus && editorLangId == 'clojure'"},
{ "key": "ctrl+oem_comma ctrl+alt+e", "command": "calva.evalCurrentFormInREPLWindow" , "when": "editorTextFocus && editorLangId == 'clojure'"},
{ "key": "ctrl+oem_comma ctrl+alt+space", "command": "calva.evalCurrentTopLevelFormInREPLWindow" , "when": "editorTextFocus && editorLangId == 'clojure'"},
{ "key": "ctrl+alt+right",        "command": "paredit.forwardSexp",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+alt+left",         "command": "paredit.backwardSexp",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+down",             "command": "paredit.forwardDownSexp",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+up",               "command": "paredit.backwardUpSexp",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+alt+right",  "command": "paredit.closeList",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+alt+w space",      "command": "paredit.rangeForDefun",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+w",                "command": "paredit.sexpRangeExpansion",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+w",          "command": "paredit.sexpRangeContraction",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+c ctrl+right", "command": "paredit.yankForwardSexp",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+c ctrl+left", "command": "paredit.yankBackwardSexp",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+c ctrl+down", "command": "paredit.yankForwardDownSexp",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+c ctrl+up",  "command": "paredit.yankBackwardUpSexp",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+c ctrl+alt+right", "command": "paredit.yankCloseList",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+c space",    "command": "paredit.yankRangeForDefun",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+x right",    "command": "paredit.cutForwardSexp",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+x left",     "command": "paredit.cutBackwardSexp",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+x down",     "command": "paredit.cutForwardDownSexp",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+x up",       "command": "paredit.cutBackwardUpSexp",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+x ctrl+alt+right", "command": "paredit.cutCloseList",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+x space",    "command": "paredit.cutRangeForDefun",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+right",            "command": "paredit.slurpSexpForward",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+left",       "command": "paredit.slurpSexpBackward",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+left",             "command": "paredit.barfSexpForward",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+right",      "command": "paredit.barfSexpBackward",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+alt+s",            "command": "paredit.spliceSexp",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+alt+s",      "command": "paredit.splitSexp",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+delete",           "command": "paredit.killSexpForward",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+backspace",        "command": "paredit.killSexpBackward",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+alt+down",         "command": "paredit.spliceSexpKillForward",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+alt+up",           "command": "paredit.spliceSexpKillBackward",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+alt+9",      "command": "paredit.wrapAroundParens",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+alt+oem_4",        "command": "paredit.wrapAroundSquare",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+shift+alt+oem_4",  "command": "paredit.wrapAroundCurly",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+alt+i",            "command": "paredit.indentRange",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "delete",                "command": "paredit.deleteForward",
                                     "when": "editorTextFocus && !editorHasMultipleSelections && !editorReadOnly && paredit:keyMap == 'strict' && editorLangId =~ /clojure|scheme|lisp/" },
{ "key": "backspace",             "command": "paredit.deleteBackward",
                                     "when": "editorTextFocus && !editorHasMultipleSelections && !editorReadOnly && paredit:keyMap == 'strict' && editorLangId =~ /clojure|scheme|lisp/" },
{ "key": "ctrl+alt+delete",       "command": "deleteRight",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "ctrl+alt+backspace",    "command": "deleteLeft",
                                     "when": "calva:pareditValid && paredit:keyMap =~ /original|strict/" },
{ "key": "tab",                   "command": "calva-fmt.formatCurrentForm",
                                     "when": "editorTextFocus && !editorReadOnly && !hasOtherSuggestions && !suggestWidgetVisible && editorLangId == 'clojure'" },
{ "key": "ctrl+alt+l",            "command": "calva-fmt.alignCurrentForm",
                                     "when": "editorTextFocus && !editorReadOnly && !hasOtherSuggestions && !suggestWidgetVisible && editorLangId == 'clojure'" },
{ "key": "ctrl+alt+p",            "command": "calva-fmt.inferParens",
                                     "when": "editorTextFocus && !editorReadOnly && !hasOtherSuggestions && !suggestWidgetVisible && editorLangId == 'clojure'" },
{ "key": "ctrl+i",                "command": "calva-fmt.tabIndent",
                                     "when": "editorTextFocus && !editorReadOnly && !hasOtherSuggestions && !suggestWidgetVisible && editorLangId == 'clojure'" },
{ "key": "ctrl+shift+i",          "command": "calva-fmt.tabDedent",
                                     "when": "editorTextFocus && !editorReadOnly && !hasOtherSuggestions && !suggestWidgetVisible && editorLangId == 'clojure'" }

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