'VScode define custom shortcut for restart and run all

I have been using VS Code for my notebooks recently. However, I really miss the "restart and run all" shortcut offered in the vanilla Jupyter notebook. I found the restart option in the setting.
enter image description here I also found the run-all option. enter image description here Is there a way that I can combine these two triggers into one?



Solution 1:[1]

There is a vscode extension called multi-command that allows you to do that. Go to your extensions, find the extension and install it. After you do that go to your keybinds and open the keybindings.json, you can do so by clicking here (pic attached).

here

Then go ahead and add the following:

{
  "key": "oem_8",                            //put whatever key you want here
  "command": "extension.multiCommand.execute",
  "args": {
    "sequence": [                            //put whatever keybind actions you want in here
      "jupyter.notebookeditor.restartkernel",
      "notebook.execute"
    ]
  },
  "when": "editorTextFocus"
}

I hope I helped!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 B. Willems