Last active
July 1, 2018 02:40
-
-
Save m4nuC/01b02ce6feac6dcda14d0323729b709f to your computer and use it in GitHub Desktop.
jupyter-vim-binding: Enable Ctrl-C to escape insert mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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