Open rezaffm opened 6 years ago
Unfortunately there are two different shortcut systems in action - Jupyter's own (which that doc explains how to configure), and Codemirror's. Codemirror is the text editor component we use for cells. So most of the editing shortcuts are caught by Codemirror's shortcut system.
Is there any "way around" or should someone actually go and use the extension to modify keyshortcuts?
There is some way around, I think, but I can never remember exactly what you need to do. Search for cm_config
in examples and be prepared for some trial and error, because I think the ways to do it have changed over the years.
Well, I think I do not have to much luck with these shortcuts: https://github.com/ipython-contrib/jupyter_contrib_nbextensions/issues/1321
I searched through google and fine some "tutorials" to change the keyboard:
However, they all do not work. Searching the CodeMirror-Side I found the "keyMap" and "extraKeys" options that you could you during the instantiation of the editor (havent tried it yet). Looking into the addons of CodeMirror (comment.js), they toggleComment-Function is still there (same name). In the keymap e.g for instance it is called: { "Ctrl-/": "toggleCommentIndented" }
I might be thinking to easy, but the whole issue for None-US keyboards could then be solved by adding an "extraKey", for instance: extraKey = {'Ctrl+Shift+7': "toggleCommentIndented}.
How can you access CodeMirror the easierst way? Could you put me on the right track here? Should someone create a custom.js and access codemirror there?
I ve been playing around, while I found out that the toggleComment is here:
Jupyter.Cell.options_default.cm_config.extraKeys
It still has no effect, whether I change the key in the console or in a config.js File.
What am I missing?
Well, so changing anything on the Cell object had no effect. The only thig that worked finally was the following (custom.js in .jupyter/custom folder):
define([ 'codemirror/lib/codemirror', ], function(CodeMirror) { CodeMirror.keyMap.pcDefault["Ctrl-7"] = "toggleComment" } );
This toggles lines no by using Ctrl and 7.
I've the same problem!! its annoying
Any chance of getting this to be part of a configurable option?
I know there is a way to manually write commands in a .js file in the jupyter notebook installation, but also editing jupyter notebook shortcuts from the shortcut menu actually works when following this strict set of rules, whereafter the notebook must be restarted:
What however is not written in there, is that some keys seem to be exempt from functionality, e.g. if you use ss
in a key combination, the key combination is added, but actually does not work
I solved it like I described here: https://stackoverflow.com/a/71480779/7056765
Well, I am getting a bit frustrated. I tried to unbind the key for commenting in edit mode following the instructions that are given here: http://jupyter-notebook.readthedocs.io/en/stable/extending/keymaps.html - but the unbinding never took place.
Consequently, also the re-binding, for instance to "Ctrl-7" never worked as well (German keyboard). So could maybe someone please provide an example configuration or tell me whether this is unexpected behavior or a case of "uts" (user to stupid)?
I ve been playing around with this for a while now and cd not solve it.