jupyter-vim-binding
jupyter-vim-binding copied to clipboard
Configuration
Summary
Environment
- [Debian 8 ] Operating system : (e.g. Ubuntu Gnome 15.04 64bit)
- [ Firefox 45.2.0] Web browser : (e.g. Firefox 44.0.2)
- [4.2.1 ] Version or revision of Jupyter Notebook : (e.g. 4.1 or 620fb29)
- [Last] Revision of jupyter-vim-binding : (e.g. 5a057d6)
I want to exit from Vim mode to Jupyter mode with pushink "ff". I could not make it myself.
Step by step procedure
- Edit ~/.jupyter/custom/custom.js this way:
require([
'nbextensions/vim_binding/vim_binding', // depends your installation
], function() {
// Map jj to <Esc>
CodeMirror.Vim.map("jj", "<Esc>", "insert");
CodeMirror.Vim.map("ff", "Shift-Esc");
O});
jj to Esc - work great, but mapping FF - "Shift-Esc (Exit from Vim mode) dont work
Shift-Esc
is a bit special assignment so you need to directly assign the mapping to extraKeys
.
var cm_config = Cell.options_default.cm_config
cm_config.extraKeys = $.extend(cm_config.extraKeys || {}, {
'ff': CodeMirror.prototype.leaveNormalMode,
});
Jupyter.notebook.get_cells().map(function(cell) {
var cm = cell.code_mirror;
if (cm) {
cm.setOption('extraKeys', $.extend(
cm.getOption('extraKeys') || {},
cm_config.extraKeys
));
}
});
The code above is just a concept and may need some modification. See https://github.com/lambdalisue/jupyter-vim-binding/blob/master/vim_binding.js#L72 for more detail.
EDIT: I modified custom.js
. Was I supposed to modify vim_binding.js
directly?
I tried the proposed solution and couldnt get this to work. OP - were you able to use it?
I have a variation of OP's question. Can I map the same key sequence (jj) to do leaveNormalMode
. That way, from insert mode, I just have to do jj
+ jj
to get to jupyterCommandMode.
Thanks for all your hard work! Jeff
Hum... Maybe the loading order issue. I need to investigate the better way to solve it. For now, modifying vim_binding.js directly would solve the problem in case if you are in rush.
Er, I tried that after I commented here but I couldnt get it working. What's more interesting (to me) is even snippets from Customization page didnt work. I'm on Mac, will that be it? If only my work allowed me to use Linux :(
Er, I tried that after I commented here but I couldnt get it working
Well if you modify the part in vim_binding.js
I mentioned, it must work.
I recommend you to check browser cache or see if different browsers led you to different result.
I'm on Mac, will that be it? If only my work allowed me to use Linux :(
I'm on Mac and Linux. At least some customizations work in both situations.
I'll double check. I appreciate you taking the time out to respond! Thank you!
On Tue, Jul 19, 2016 at 8:33 PM, Alisue [email protected] wrote:
Er, I tried that after I commented here but I couldnt get it working
Well if you modify the part in vim_binding.js I mentioned, it must work. I recommend you to check browser cache or see if different browsers led you to different result.
I'm on Mac, will that be it? If only my work allowed me to use Linux :(
I'm on Mac and Linux. At least some customizations work in both situations.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lambdalisue/jupyter-vim-binding/issues/80#issuecomment-233829682, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKj9MoXUnj7ztz8IJHzCe0pqJgKvtIeks5qXZbugaJpZM4JMDGq .