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?
Following worked for me:
require(["codemirror/keymap/sublime", "notebook/js/cell", "base/js/namespace"],
function(sublime_keymap, cell, IPython) {
cell.Cell.options_default.cm_config.keyMap = 'sublime';
cell.Cell.options_default.cm_config.extraKeys["Ctrl-Enter"] = function(cm) {}
var cells = IPython.notebook.get_cells();
for(var cl=0; cl< cells.length ; cl++){
cells[cl].code_mirror.setOption('keyMap', 'sublime');
cells[cl].code_mirror.setOption("extraKeys", {
"Ctrl-Enter": function(cm) {}
});
}
}
);
you can prevent the ctrl+enter produce a new line in jupyter notebook by comment out the following line:
cmds[map[ctrl + "Enter"] = "insertLineAfter"] = function(cm) { insertLine(cm, false); };
in the file:
[python lib path]/dist-packages/notebook/static/components/codemirror/keymap/sublime.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With