7

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.

2

4 Answers 4

15

For anyone googling, this was my approach that has worked rather well

CTRLK + CTRLS brings the Keyboard Shortcuts menu.

keyboard shortcuts

At the top, in the search bar, type run python file.

enter image description here

From there, you can add a keybind to the Run Python File tag.

Sign up to request clarification or add additional context in comments.

2 Comments

This should be the right answer! And it's very useful for other things too.
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/…
6

You can refer to the picture below to find the shortcut key and change it according to your needs.

enter image description here

enter image description here

2 Comments

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).
@Convexity This is the function provided by extension code-runner
3

You can press Ctrl + F5 to run the file.

If you want to debug the file, use F5 instead.

1 Comment

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.
-1

CTRLK + CTRLS brings the Keyboard Shortcuts menu. is the right answer!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.