3

I use VS Code on a Mac laptop. If I'm using Python I can run the code by pressing the little arrow in the top right,

enter image description here

However, I can't seem to find a keyboard shortcut for this. There is an old question, How to execute Python code from within Visual Studio Code, but all the answers there seem either to be obsolete or not to work on a Mac. One of them says that the F5 key should work, but my Mac has a useless touchbar instead of function keys so it's no help to me.

tl;dr is there a shortcut to run Python code on a modern VS Code installation besides F5, or an easy way to set one up?

N. Virgo
  • 7,970
  • 11
  • 44
  • 65

3 Answers3

5

I'm using Windows so i can't give you a specific answer. But Code > Preferences > Keyboard Shortcuts, search with keyword run python file, you will get related shortcuts.

Molly Wang-MSFT
  • 7,943
  • 2
  • 9
  • 22
  • 2
    Thank you, this was helpful. Nothing was bound there, so I bound my own. I'll probably accept this after a while. – N. Virgo Nov 16 '21 at 07:22
  • @Nathaniel. Okay :) – Molly Wang-MSFT Nov 16 '21 at 07:26
  • I also use Windows mostly, I feel usually you can find the key binding information for some buttons when you hover on them, for example "Split Editor Right(Ctrl + \)" for split button usually on the right top of a editor view. If there is no such info, the corresponding binding is empty and you can set your own usually. – rustyhu Nov 16 '21 at 09:46
1

I think you can bind the shortcut by yourself.

enter image description here

enter image description here

enter image description here

Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13
0

You can try with ctrl+shift+b in windows or ⌘+shift+b in MacOS.

Tony
  • 618
  • 12
  • 27