Home > Enterprise >  Is there an option to run the code on VS code
Is there an option to run the code on VS code

Time:10-22

I used to work in PyCharm, but recently started working with the Visual Studio Code Mac version. I faced a problem after using pycharm. I downloaded the code runner extension, but still, it’s not good. When I hit the run button, it runs not the last code. So if I change something in my code and run it again, it keeps running the old version, until I save it or run via terminal.

For example:

print(“hi”)

I hit run and the output is: hi

Add something new

print(“hi”)
print(123)

Hit run and The output is still - hi


Can someone help me, so when I hit the run button it will run the code with the latest changes.

CodePudding user response:

By default, VSCode does not save your code changes before running a task. You can enable it, though. Open the Preferences and search for "save before run" and then set it to always.

CodePudding user response:

As far as i understand your problem, in VSCode you need to save your code everytime you update it. In PyCharm as far as i remember it does it automaticly for you anytime you write something more down. This is not the case with the VSCode. You have to manualy save your code. Try using Ctrl S (On Windows) to save your code. Normaly in VS you get a grey-ish bullet next to your file name indicating your file is not saved. So it will run the last saved version.

Hope i helped!

  • Related