Search code examples
windowssublimetextkey-bindingscodemirrorjupyter-notebook

Disable Ctrl+Enter sublime keymap in jupyter notebook


I'm using Jupyter Notebook with the Sublime Text keymap, by adding the following to my Jupyter custom.js:

require(["codemirror/keymap/sublime", "notebook/js/cell"], 
function(sublime_keymap, cell) {
    cell.Cell.options_default.cm_config.keyMap = 'sublime';
});

...which works great mostly, except that I'm on a Windows machine and this adds the Sublime functionality of "insertLineAfter" to the binding for Ctrl+Enter, which I don't want because Ctrl+Enter is the binding to execute the current cell in Jupyter.

Does anyone know how to disable just the "insertLineAfter" binding for Ctrl+Enter please?


Solution

  • Individual Sublime Text key bindings can be disabled using the unbound command in your Default (OS).sublime-keymap file. i.e. Menu --> Preferences --> Key Bindings - User. In your case simply add the following line.

    { "keys": ["ctrl+enter"], "command": "unbound" },
    

    Since the Add Line.sublime-macro is quite useful you may wish to give it another binding, for example you could use alt+enter or super+enter in which case you would add the following.

    { "keys": ["ctrl+enter"], "command": "unbound" },
    
    { "keys": ["alt+enter"], "command": "run_macro_file", "args": 
        {"file": "res://Packages/Default/Add Line.sublime-macro"} },