Ctrl+P and Ctrl+N for navigation in jupyter notebooks -
i'm used emacs navigation, in particular ctrl+p, n, f, , b, i'm used jupyter notebooks now. general question is: how enable shortcuts in notebook?
what tickles me fact on mac keybindings in place in standard anaconda ipython. it's understandable since system , browser shortcuts bound cmd instead of ctrl.
since spend lot of time in ubuntu, wanted reproduce same behaviour here. became apparent browsers hold of keybindings dearly, such ctrl+p print or ctrl+n new window. turning these off huge matter in itself, decided use browser solely jupyter notebook, , vivaldi seems nice choice since shortcuts customizable there.
i believed browser shortcuts being turned off, ipython syntax kick in, none such thing has happened. next tried 1 of many manuals on jupyter notebook shortcuts customization (such 1 http://jupyter-notebook.readthedocs.io/en/latest/examples/notebook/custom%20keyboard%20shortcuts.html) bind 4 shortcuts need. works extent , in jupyter inline magic:
%%javascript jupyter.keyboard_manager.command_shortcuts.add_shortcut('ctrl-p', 'jupyter-notebook:move-cursor-up')
what cursor in command mode indeed move when press ctrl-p, behaviour unstable. moreover, after moves, enters edit mode in cell above, isn't happening if press 'up' arrow. same trick edit mode:
%%javascript jupyter.keyboard_manager.edit_shortcuts.add_shortcut('ctrl-p', 'jupyter-notebook:move-cursor-up')
alas, doesn't work @ all.
forgive me prolonged intro. questions have are:
what wrong key bindings use in inline mode? silly mistake made or jupyter glitch?
when try use these byndings through custom.js file, not work. however, file recognized, e.g. alert() commands work fine.
i've stumbled few times on emacs-bindings codemirror, however, far understood, used copy-paste related matters rather navigation, true? use set of bindings instead of pursuing path custom.js?
thank you.
upd
installing emacs.js codemirror , adding code solved problem. had make sure conflicting browser keybindings turned off.
require(["codemirror/keymap/emacs", "notebook/js/cell", "base/js/namespace"], function(emacs_keymap, cell, ipython) { cell.cell.options_default.cm_config.keymap = 'emacs'; var cells = ipython.notebook.get_cells(); for(var c=0; c< cells.length ; c++){ cells[c].code_mirror.setoption('keymap', 'emacs'); } } );
Comments
Post a Comment