-
-
Notifications
You must be signed in to change notification settings - Fork 136
Enable <C-c> mapping to exit insert mode doesn't work #100
Comments
I currently does not have an environment to test but does the following code helps you? // ~/.jupyter/custom/custom.js
require([
'jquery',
'base/js/namespace',
'notebook/js/cell',
'nbextensions/vim_binding/vim_binding', // To call the function after 'vim_binding'
], function($, ns, cell, vim_binding) {
"use strict";
var Cell = cell.Cell;
// Update default config
var cm_config = Cell.options_default.cm_config;
cm_config.extraKeys = $.extend(cm_config.extraKeys || {}, {
'Ctrl-C': CodeMirror.prototype.leaveInsertMode,
});
// Update existing config
ns.notebook.get_cells().map(function(cell) {
var cm = cell.code_mirror;
if (cm) {
cm.setOption('extraKeys', $.extend(
cm.getOption('extraKeys') || {},
cm_config.extraKeys
));
}
});
}); If not, I need time to investigate... |
The code above is an essence of https://github.com/lambdalisue/jupyter-vim-binding/blob/master/vim_binding.js |
Ah, sorry I got the problem by reading the code. The code above won't work |
https://github.com/lambdalisue/jupyter-vim-binding/blob/master/vim_binding.js#L70-L74 These lines overwrite mappings written in |
Currently I don't have enough time for this project. So anyone? |
This is important to me. I will try to have a look to make a reasonable PR when I get the chance... In the meantime, for anyone coming here, a workaround can be to simply edit the source code of the extension (i.e. // ...
var cm_config = Cell.options_default.cm_config;
cm_config.keyMap = 'vim';
cm_config.extraKeys = $.extend(cm_config.extraKeys || {}, {
'Esc': CodeMirror.prototype.leaveInsertMode,
'Shift-Esc': CodeMirror.prototype.leaveNormalMode,
'Ctrl-C': CodeMirror.prototype.leaveInsertMode,
//'Ctrl-C': false, // To enable clipboard copy
});
// ... |
Summary
Tried to use the code from the customization wiki to enable <C-c> for exiting insert mode.
Behavior
Expected
It should rebind <C-c> to exit insert mode.
Actual
When loading notebook, in custom.js:
Step by step procedure
Paste into ~/.jupyter/custom/custom.js:
What you have done to solve the issue
Pasting the code from custom.js into the browser console after load works, as does changing
to
in vim_bindings.js, similar to what was suggested in #80. I didn't really like changing code from the repository for configuration, so I tried to change the binding again in custom.js:
It's basically the same code from the wiki, but it sticks the code into the exports.attach function from vim_bindings.js. This works for me.
Remarks
I'm still not sure if it's just an issue on my end that prevents the wiki's custom.js script from working. If other people have had the same issue and my solution works for them I'd like to add it to the customization wiki.
The text was updated successfully, but these errors were encountered: