In VS Code, I'm writing python code. I was wondering if there is a key shortcut to run the file instead of pressing the run button in the right top corner of the screen constantly.
-
Does this answer your question? How to execute Python code from within Visual Studio Codezaibaq– zaibaq2022-04-27 08:54:06 +00:00Commented Apr 27, 2022 at 8:54
-
what does the official VSC doc say about PythonrioV8– rioV82022-04-27 09:37:45 +00:00Commented Apr 27, 2022 at 9:37
Add a comment
|
4 Answers
For anyone googling, this was my approach that has worked rather well
CTRLK + CTRLS brings the Keyboard Shortcuts menu.
At the top, in the search bar, type run python file.
From there, you can add a keybind to the Run Python File tag.
2 Comments
Ajean
This should be the right answer! And it's very useful for other things too.
Convexity
Alt+R was a good choice (used for toggle regex in searches, which you need less often). Some said that Python: Run Python File in Terminal worked better than Python: Run Python File, so try the latter if you have problems: reddit.com/r/learnpython/comments/p1c6k5/…2 Comments
Convexity
I did not find anything with "run code", but the "run python" in stackoverflow.com/a/75959097 below worked. Alt-R was a good choice (used for toggle regex in searches, which you need less often).
MingJie-MSFT
@Convexity This is the function provided by extension code-runner
You can press Ctrl + F5 to run the file.
If you want to debug the file, use F5 instead.
1 Comment
Ajean
That doesn't actually do the same thing. The button just runs the file in a Python terminal, the default command associated with Ctrl+F5 will run the file in the Python debugger, just with the debugging turned off.



