Jupyter/IPython Notebooks: Shortcut for “run all”?

后端 未结 6 1095
一整个雨季
一整个雨季 2020-12-22 20:23

Is there a shortcut to run all cells in an IPython notebook?

And if not, does this have a specific reason?

6条回答
  •  醉话见心
    2020-12-22 21:07

    Jupyter Lab 1.0.4:

    1. In the top menu, go to: Settings->Advanced Settings Editor->Keyboard Shortcuts

    2. Paste this code in the User Preferences window:

    {
        "shortcuts": [
            {
                "command": "runmenu:run-all",
                "keys": [
                    "R",
                    "R"
                ],
                "selector": "[data-jp-kernel-user]:focus"
            }
        ]
    }
    
    1. Save (top right of the user-preferences window)

    This will be effective immediately. Here, two consecutive 'R' presses runs all cells (just like two '0' for kernel restart). Notably, system defaults has empty templates for all menu commands, including this code (search for run-all). The selector was copied from kernelmenu:restart, to allow printing r within cells. This system defaults copy-paste can be generalized to any command.

提交回复
热议问题