-
-
Notifications
You must be signed in to change notification settings - Fork 136
Can one map Ctrl-j/k to other operations instead of running cell and jumping to cell up/down? #123
Comments
In case if you miss, did you check https://github.com/lambdalisue/jupyter-vim-binding/wiki/Customization ? Please write what you've tried and how did you fail with some sample code. |
Thanks for response. I uncommented the last two lines, but this take no effects, just as the comment itself says "The following key mappings should not be defined" |
Then how about a bit modification of https://github.com/lambdalisue/jupyter-vim-binding/wiki/Customization#run-cell-scrolls-the-cell-to-top-scroll-output-into-view // Run and select next cell
Jupyter.keyboard_manager.actions.register({
'help': 'run selected cells',
'handler': function(env, event) {
env.notebook.command_mode();
var actions = Jupyter.keyboard_manager.actions;
actions.call('jupyter-notebook:run-cell', event, env);
actions.call('jupyter-notebook:select-next-cell', event, env);
env.notebook.edit_mode();
}
}, 'run-and-next', 'vim-binding');
// Run and select previous cell
Jupyter.keyboard_manager.actions.register({
'help': 'run selected cells',
'handler': function(env, event) {
env.notebook.command_mode();
var actions = Jupyter.keyboard_manager.actions;
actions.call('jupyter-notebook:run-cell', event, env);
actions.call('jupyter-notebook:select-previous-cell', event, env);
env.notebook.edit_mode();
}
}, 'run-and-previous', 'vim-binding');
// Add two keyboard shortcuts for the new actions
require([
'nbextensions/vim_binding/vim_binding',
'base/js/namespace',
], function(vim_binding, ns) {
// Add post callback
vim_binding.on_ready_callbacks.push(function(){
var km = ns.keyboard_manager;
// Indicate the key combination to run the commans
km.edit_shortcuts.add_shortcut('ctrl-j', 'vim-binding:run-and-next', true);
km.edit_shortcuts.add_shortcut('ctrl-k', 'vim-binding:run-and-previous', true);
// Update Help
km.edit_shortcuts.events.trigger('rebuild.QuickHelp');
});
}); Note that all available jupyter mappings are written in https://github.com/lambdalisue/jupyter-vim-binding/blob/master/lib/jupyter/shortcuts.js |
I want to map c-j to 5j, namely jump up 5 lines, and I tweaked the lines |
Someone like me maybe acoustomized to use Ctrl-j/k in other ways, say, jump up/down several lines. How can I bind "running cell and jumping to cell up/down" with other keys, and release Ctrl-jk, so that I can use them as I want?
The text was updated successfully, but these errors were encountered: