Skip to content

Instantly share code, notes, and snippets.

@m4nuC
Last active July 1, 2018 02:40
Show Gist options
  • Save m4nuC/01b02ce6feac6dcda14d0323729b709f to your computer and use it in GitHub Desktop.
Save m4nuC/01b02ce6feac6dcda14d0323729b709f to your computer and use it in GitHub Desktop.
jupyter-vim-binding: Enable Ctrl-C to escape insert mode
// Bind <C-c> to exit insert mode
require([
'nbextensions/vim_binding/vim_binding',
], function(nb) {
CodeMirror.Vim.map("<C-c>", "<Esc>", "insert");
nb.attach = (function() {
var cached_function = nb.attach;
return function(){
var result = cached_function.apply(this, arguments);
var cm_config = require("notebook/js/cell").Cell.options_default.cm_config;
delete cm_config.extraKeys['Ctrl-C'];
Jupyter.notebook.get_cells().map(function(cell) {
var cm = cell.code_mirror;
if (cm) {
delete cm.getOption('extraKeys')['Ctrl-C'];
}
});
return result;
}
})()
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment