8

I have python script with jupyter notebook mark #%% which describe that I can run this script in visual studio code python interactive.

Acccording to this:

Jupyter/IPython Notebooks: Shortcut for "run all"?

I have similar question because described solution does not work in my case. How to specify shortcut for jupyter notebook command 'run all' in visual studio code?

ElConrado
  • 1,477
  • 4
  • 20
  • 46

1 Answers1

6

You can create your own keyboard shortcut by modifying the keybindings.json file by clicking on

File > preferences > keyboard shortcuts

Then clicking on the link - (bottom right of the image below) enter image description here

You can also install the code runner extension.

Code runner will add a play button on the top right of the vs code window, which you can click to run your code.

Nick
  • 3,454
  • 6
  • 33
  • 56
  • 5
    Great, that's what I need. I think you can edit your answer for more precisely with 'search for 'python.datascience.runallcells' in keybindin'. – ElConrado Mar 21 '19 at 10:10
  • 1
    Hey Elconrado. I'm a developer on the Python extension. You already have the right advice for the keybinding from the comment above. But just to mention. There is also the "Python: Run Current File in Python Interactive window" that one will work regardless of if cells are defined or not, and is available from the command palette and from right click context menu in the editor for a .py file. – Ian Huff Mar 21 '19 at 16:10
  • @IanHuff any idea how to configure other shortcuts such as deleting/cutting a cell? after looking for `python.datascience` under keyboard shortcuts I couldn't see any relevant field – pcko1 Jan 13 '20 at 09:25
  • 1
    @pcko1 Sorry about the super late reply, I was off SO for a while. So for cell commands we are not able to customize them as our editor is a separate webview from the main vscode process. We support about 1/3 of existing jupyter commands (like dd to delete a cell) but they can't currently be customized. Something that we would like to do but difficult due to the webview being separate. – Ian Huff Feb 25 '20 at 19:17