How to add keyboard shortcuts permanently to Jupyter (ipython) notebook?

前端 未结 4 682
野的像风
野的像风 2021-01-04 11:49

I have the following configuration for shortcuts, that works after running it in the cell of Jupiter notebook:

%%javascript


IPython.keyboard_manager.comman         


        
4条回答
  •  被撕碎了的回忆
    2021-01-04 12:14

    1. For changing command mode shortcuts: refer Salvador's answer

    2. For changing edit mode shortcuts:

    Edit the file, ~/.jupyter/nbconfig/notebook.json as explained on https://jupyter-notebook.readthedocs.io/en/stable/extending/keymaps.html

    For example, after replacing the control-enter shortcut to execute code, with command-enter on macOS, the file looks like this:

    {
      "Notebook": {
        "Toolbar": true,
        "Header": true
      },
      "Cell": {
        "cm_config": {
          "lineNumbers": true
        }
      },
      "keys": {
        "command": {
          "unbind": [
            "ctrl-enter"
          ],
          "bind": {
            "cmdtrl-enter": "jupyter-notebook:run-cell"   
          }
        }, 
        "edit": {
          "unbind": [
            "ctrl-enter"
          ],
          "bind": {
            "cmdtrl-enter": "jupyter-notebook:run-cell"
          }  
        } 
      }   
    } 
    

提交回复
热议问题