Creating and Running a Code Snippet
00:00 In this second video, we’ll create and run our little code snippet in Visual Studio Code. Once you open up a new project with VS Code, this is kind of the screen that you’re going to be greeted with.
00:11 We can see some helpful information here. I don’t want to deal with this right now, but obviously you can read over it. If I close it, what is also nice, I think—there’s a couple of other helpful features that are just shortcuts that are shown here. And we’ll look at those… let’s do it right now!
00:27 So let’s take a look at some of the most common ones. Show All Commands, Command + Shift + P—press this combination. I’m going to create a new file in here, so I say “new file” and right away, it gives me—I can make a new file here with this command, or it also shows me what’s a keyboard shortcut that I can use for that.
01:09 You can see that there’s also a symbol, here, on the left side. It shows us that it’s a Python file. This is all customizable, so if you don’t want to have these specific symbols there, you can change them, et cetera. But yeah, I’m happy with them. So let’s go ahead, maybe increase the font size a bit. I just press Command + Plus, and that will make it much easier to see…
because all we’re writing is just a little script. So
for x in range(), we’re already pretty used to that. And as you see popping up here, we have code completion, that’s also called IntelliSence. It’s a mix of both code completion, which allows me to just Tab complete something—so
range, you see here, I can select multiple ones and I want
range, and then I open up these brackets and it gives me the documentation for this function. So I can read about it: What is it about? What do I want to do? This works both for inbuilt functions and also stuff that you’re going to write yourself. So, very useful.
It might be sometimes a little bit annoying, but you can customize all of this stuff. All right. And print out our
x. Here we are. And now I want to run this file. So I can save it with Command + S and you see that this circle up here changes to an X. That means I know that it’s saved.
03:27 So, these are some easy ways to just create the script and run it. We can see, we have all the nice features that we want from a modern text editor. We have syntax highlighting, we have code completion, we have inspection of the documentation of what’s going on in the functions, et cetera. So it’s an easy tool to get started, everything is relatively straightforward.
Become a Member to join the conversation.