Visual Studio Code for Python Developers Transcripts
Chapter: Exploring the Editor
Lecture: Common Shortcuts
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
All right, brace yourselves for this video because we are going to take a look at keyboard shortcuts in Visual Studio Code.
0:07
And I say brace yourselves because this is something that I'm personally passionate about in the sense of I want to be efficient and keep my hands on the keyboard as much as possible without having to touch the mouse or do anything else off of the keyboard.
0:19
Now, while I say that, I'm also, I don't know every keyboard shortcut possible.
0:24
I do know a lot of keyboard shortcuts in Visual Studio Code, but I don't know all of them or haven't used them all efficiently.
0:30
But the idea is you'll be able to learn them on your own.
0:33
And I'm going to give you a highlight of some of my favorite ones that I think you'll find useful to help you in using Visual Studio Code for writing your Python projects.
0:42
Now, to start us off, though, let's first talk about how to learn shortcuts.
0:47
Often the way that I come across new keyboard shortcuts is by through the visual indications that VS Code offers to you.
0:54
So if you open up any menu, you'll notice to add a new text file. There's a keyboard shortcut associated. With it, that is displayed in that action.
1:02
So control and on this in this case, if you're on Mac, it'll be command and right and so forth. Some of the other ones, new file, new window.
1:10
This is a great way to get acquainted with some of the common things that you're doing that are you're like manually doing.
1:16
But with your mouse, you can find the keyboard shortcut associated with that action in the menu of items that are there.
1:22
Or if you hover over certain things. So let's say I wanted to instead of showing the Explorer view, which I have available right now.
1:30
I can see that that is associated with the keyboard shortcut of control shift E or run and debug control shift D.
1:37
So that's how I go about learning new keyboard shortcuts.
1:40
And it's a nice little quality of life improvement that VS Code has had for quite some time now so that you can get more acquainted with new keyboard shortcuts and start incorporating it into your workflow.
1:50
That's one way you can learn about it through the UI. Another way I like to do it, and this is probably the number one keyboard shortcut.
1:57
If there's one keyboard shortcut you remember from. This course in this video, it's control shift P or command shift P.
2:05
This opens up that command palette, which I believe we discussed previously and got you a little bit acquainted with it.
2:11
But that's the gateway to everything in Visual Studio code along with the keyboard shortcuts that are associated with it.
2:17
So if I wanted to create a new file. Let's do a new file. I can see that create new file has a keyboard shortcut associated with that control.
2:29
Alt windows plus N.
2:31
If I wanted to open something like open the keyboard shortcuts in particular, there's a keyboard shortcut for that control K and then control S on on Windows and Linux.
2:42
So I'm going to hit enter to bring that up because this is the third way that you can learn about new keyboard shortcuts.
2:49
You can search for certain actions or commands that you would like and find the key binding that's associated with that in this table.
2:55
There's even conditions and you can associate them with certain. Operating systems as well if you'd like.
3:01
So this is the keyboard shortcuts view that gives you the overview of every possible keyboard shortcut and key binding that is saved and associated with Visual Studio code or any custom ones that you create.
3:12
So that's how you access the shortcuts view. Now if you want to create, let's say a custom keyboard shortcut, you can either override an existing one.
3:22
So like except chat input or except inline completion, I can click edit and type in whatever I want for the keyboard shortcut. So maybe. Control.
3:30
I don't know. L will just make it up for now.
3:32
It lets you know, by the way, that there are three existing commands that have this key binding that you will probably interfere with.
3:38
So just heads up on that, but you can hit enter, press the enter key to then save that key binding to that command.
3:45
I'm going to hit escape to undo that twice because I don't want to override this existing one.
3:50
So that's kind of a quick overview of how you can get acquainted with keyboard shortcuts. Again, it's through visual indications, the command palette.
3:59
Control shift P or in the keyboard shortcuts view directly.
4:04
Now one thing I'm going to do to help with the rest of this course, I'm going to enable what's called screencast mode.
4:09
Developer toggle screencast mode.
4:12
And what this is going to do is it's now going to visually display whatever key bindings or keyboard shortcuts I'm using or actions that are happening.
4:19
So you can get that available to you and I'll do my best and Cecil as well to keep this on throughout the rest of the course.
4:25
You'll also notice every time I click, it'll highlight in red as well.
4:29
So if you're somebody that wants to create a video or tutorials or anything like that, or you're displaying doing a presentation to your colleagues, it might be a setting you might want to turn on to help improve the experience of those folks that are viewing that.
4:41
All right, so let's jump into some of my commonly used keyboard shortcuts that I find useful. First up, we talked about control shift P, right?
4:49
That brings up the command palette and then I can search for any other command that I want. If I want to add one like a custom one.
4:55
So this one right here, like open settings UI doesn't have any. Keyboard shortcut associated with it. I can click edit on it.
5:02
And then in this case I can go add and then put that one in there too. So that's just a heads up on that one as well.
5:08
Another way to go about adding, instead of overriding keyboard shortcut, you can add a keyboard shortcut.
5:13
Another one I commonly use is once I have a file open that I want to edit like this one here, the API dot PI, I don't need to see the Explorer view or whatever it might be open.
5:22
Maybe I have run and debug open anything in the side panel. If I want to minimize that I press control B.
5:28
And that toggles the visibility of the primary sidebar as you saw here. Now really quick, this is a personal preference.
5:34
I don't really like this view being on the right hand side because of how common I use this keyboard shortcut and you see how visually jarring it is to keep my eyes on the code when I'm doing that.
5:44
So what I like to do is I like to turn, move the activity bar and this whole Explorer view sidebar rather to the right hand side.
5:51
And the way you can do that is bring up the command palette. and it's toggle primary sidebar. And you can see that it's in the right hand side.
5:59
So I'm going to go ahead and drag and drop this. And you notice now it's on the right hand side.
6:01
And when I press control B now to hide that visibility of that, notice how it's less jarring. I love that. It's so much better. Thank me later.
6:09
All right.
6:10
So that's control B. Now, if I need to use the terminal to run any type of commands on my operating system or Python commands to run things, what have you, if you need to view the terminal, the way you do that is control back tick.
6:22
And you'll notice it popped open this terminal here. And then I can start running whatever commands I want.
6:28
I need to do here, like clear the screen or whatnot. Right. Change directories, all that fun stuff.
6:33
If I want to hide that though, I just press it again.
6:36
Now, one other thing that I personally edit is the whole that's to bring up specifically the terminal view.
6:42
Then there's other ones for the debug console, maybe the output.
6:46
You can see I'm hovering over them or any problems that, VS Code is trying to alert me to about my project.
6:51
Remember that control back tick is specifically to bring you to the terminal and oftentimes this bottom panel. I always.
6:57
Have the terminal tab visible in here, but I want to sometimes just hold like a quicker keyboard shortcut.
7:03
It's a little hard for me to like my dexterity in my hands to press control back tick every time. Although I do use that sometimes.
7:11
So I added another keyboard shortcut control J to toggle the panel visibility.
7:16
Now, the reason I'm calling this out is if I have the debug console selected in here and I press control J to hide it and bring it back.
7:24
It's always whatever the last visible tab in the bottom panel. Was open is what's going to show up in there. So that's just something to note.
7:31
And the reason I did control J, it's one of those keyboard shortcuts. It's not associated with anything else.
7:36
And I also added one because you can expand the terminal or this bottom panel to take up the full view, within Visual Studio Code.
7:43
If you normally, you would just click on this. I added a keyboard shortcut instead of having to click on that. I added control shift J.
7:49
Oh, it's not in this profile. Actually, let's go at it real quick. So if I want to add one, I know that this action or command is called.
7:57
Maximize panel by hovering over it.
7:59
So let's bring up the keyboard shortcuts, open keyboard shortcuts, and I'm going to search for, let's clear this from before.
8:07
I'm going to search for maximize panel. I'm going to click plus control shift J hit enter. It said one existing command use that. Okay.
8:23
Well, I don't know what that other existing one was. Let's try that again. Really quick. Out of curiosity.
8:27
You can click on that to see workbench action search toggle query details. Yeah, I never really use that, so I don't know about that one.
8:36
So it's okay that I'm overwriting that for my purposes, maybe not for yours. Okay.
8:40
So what does that do now that I added that well control J just hides and shows that bottom panel.
8:45
But when it's small like this, I can press control shift J to maximize it and then bring it back to its previous size.
8:51
The nice one to have that I like in a little, little added bonus tip in there for you. Okay.
8:57
Well, we talked about control shift E to show the explorer view or control B just to hide it in general. Kind of like control J.
9:03
What's what else do we have here? If I need to search for something within a file, I press control F and that brings up the editor view file search.
9:13
So if I want to find, yeah, like shows router or API dot anywhere I'm using that I can then see that you can expand this to then replace it as well, which I believe the toggle replaces a there's a keyboard shortcut associated with that too.
9:26
I thought as well. But I might be wrong on that. You notice this one replace you hit enter.
9:31
If you wanted to replace API with like, I don't know, test that first one probably messed it up or no, I just typed it there.
9:39
So here's a keyboard shortcut. I use that with any text editing type of software.
9:43
These are common keyboard shortcuts that maybe you already know, but just in case folks that don't know, like I made this mistake that I want to undo control Z will undo that.
9:50
And so now that API was changed back to, or from test to back to API rather. Close that out. All right. So that is control fine.
9:59
But if I want to find like a certain string of text through my whole project that or workspace that I'm having, I currently have open, I can press control shift F and that brings up the broader search view, which now I can look for API in across the entire project anywhere.
10:16
That instance is not just in the currently open file API dot PI.
10:20
I'm looking in project Tomel PI project Tomel ring, read me and all that fun stuff there.
10:25
And then if I want to clear that, I can hide that control shift F to toggle it back off or no rather let's just do control B to hide that. Okay.
10:37
Next up, speaking of editing, let's hide that for a second while we're editing some keyboard shortcuts more. We talked about control Z.
10:45
What else can we do in here that I use often is there's a thing called multi-cursor actions in Visual Studio Code that you might not have in a regular old text editor, like
10:55
notepad or something like that. And that is possible by one. There's a couple of different ways you can actually make that possible.
11:01
One common way that I do it is let's say I wanted to edit all of these three lines of API dot to something else.
11:06
I can press on Windows and Linux control alt down arrow down arrow and you'll notice there's two or two or three now blinking cursors.
11:15
And as I move it over, they're moving in in concert together there. Right. And now I can press like control shift right arrow to select that. Okay.
11:25
And I can say maybe I want to call that test instead. Right. And you notice how it edits multiple lines at the same time, all in sync together.
11:32
So keep that in mind. One other way to go about doing this.
11:35
If you have like a common function name or something like that, you can press F two over it and it's like edit enter to rename shift, enter to preview.
11:44
So if I call that test now and now I'm, you know, assigning tests to FastAPI, and then I can use the functions off of that as well.
11:53
I want to do that again. That's another way to do it. F two is to rename when you're renaming like a variable.
11:59
That's something that's specific to Visual Studio Code, but maybe you have like a string of text that is not necessarily a variable that you want to edit and you know, it's in multiple places, even in comments and stuff like that.
12:09
Well, in that case, you can highlight it and then you can, and you notice how VS Code kind of highlights the other ones that are even case insensitive throughout the rest of this file.
12:19
I can press control D to select each instance of that slowly. So I wanted those three in just the comment there.
12:24
I want to change that to like test if I wanted to as well. It did that in all cases, if I want to select all of them at once.
12:32
So I go like this and I can press control shift L and that selects all instances at once.
12:38
So control D to select them slowly, but surely for which one that you want. In fact, you don't even need to have it selected.
12:44
You can just have the cursor right in front of it. And then it'll slowly add.
12:48
Actually, if you want it, if you want it to be case insensitive, you should select it.
12:51
I'm just realizing this now making this, but if you don't do that, you're going to have to do it.
12:54
Then you can just press control D and step through each one that you want. So maybe I didn't want that last one. I go back up to the top here.
13:02
It allows me to slowly pick which ones I want there. Okay. All right. What else we got control shift L we talked about control shift D.
13:10
What does that do? That will bring up the debug view, right? In case you're done editing, you're ready to run your Python code.
13:17
Now you can come in here and use the run and debug view within Visual Studio Code. Let's hide that. We got next, we got control slash.
13:26
This should be fairly common for most developers in Visual Studio Code.
13:29
If you want to comment out a line of code, you bring your cursor to that line and you press control forward slash. And that will comment it out.
13:37
And you notice it uses the appropriate one for the language that we're working within. In this case, Python.
13:42
If you want to undo that control Z again, if you want to redo something, we've been talking about control Z.
13:47
If you want to redo it, you can press control shift Z to redo that thing back and forth.
13:51
So if control Z to undo controls, Z, two, one, and then you're done.
13:54
You can press control shift Z to redo control shift Z to redo rather control space. Something I want to tell you about.
13:59
That's I think specific to Visual Studio Code, maybe some other editors and IDs out there help with this.
14:04
But the interesting thing here is let's say API.
14:08
Now, typically when you press dot, it will bring up this what's called like IntelliCode IntelliSense that's available in Visual Studio Code to let you know of all the different properties and functions that are available for that particular item.
14:20
If that doesn't show up for you, you can manually trigger that by pressing the button. You can also trigger that by pressing control space.
14:25
Sometimes that happens to me and that way I can start intentionally turning that visualization on and I can explore for which one I want.
14:34
You can start typing out what I might be looking for and that highlights it even more for me.
14:39
Highlights more specifically what might be relevant to what I'm looking for. Getting towards the end of the shortcuts here and there's plenty here.
14:45
This is not a comprehensive list of shortcuts, but it's one of the common ones that I like to use. F5. I'm not going to press it right now.
14:52
But you can. If you're using our project, they'll be there for you. If you're using our project, they'll be there for you.
14:55
But if you're creating your own, you can get into creating a what's called a launch configuration in Python. More on that in another video.
14:57
And last but not least, we talk about custom shortcuts. I showed you one, my control J and control shift J.
14:59
One other one that I like to do is sometimes Visual Studio Code is a little bit more complicated. I'm going to show you how to do that.
15:01
So I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:04
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:07
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:10
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:13
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:16
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:19
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:22
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:25
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:28
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:31
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:34
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:37
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:40
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:43
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:46
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:49
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:52
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:55
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
15:58
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:01
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:04
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:07
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:10
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:13
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:16
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:19
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:22
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:25
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:28
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:31
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:34
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:37
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:40
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:43
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:46
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:49
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:52
I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts. I'm going to go to my custom shortcuts.
16:55
I'm going to go to my custom shortcuts. for custom and common keyboard shortcuts in Visual Studio Code. In the next video, we're
17:02
going to start talking about extensions that you can use that are just common ones that
17:05
me and Cecil like. We're going to present those to you and talk a little bit more about them.