Become a VS Code Power User

Using the Command Palette

Steve Kinney
Temporal
Become a VS Code Power User

Lesson Description

The "Using the Command Palette" Lesson is part of the full, Become a VS Code Power User course featured in this preview video. Here's what you'd learn in this lesson:

Steve demonstrates different ways to open a folder and provides a brief overview of the different sections in the interface, such as the file explorer, activity bar, and status bar. He also provides an example using the command palette to sort lines of code.

Preview
Close

Transcript from the "Using the Command Palette" Lesson

[00:00:00]
>> Steve: So this is Visual Studio code you might have seen it before. Some tasty notes as I jump in, I mostly set all of my environment back to like standard, vanilla setup. Some changes are like left some extensions installed, because when we get to exploring extensions watching means all of them one by one seemed terrible, right?

[00:00:25]
So some of them are installed, but other than that, I wiped away all of my key bindings, all of my snippets, everything. So I'm hopefully starting as close to a tabla rasa as anyone else. You do not need to do the same, but I do because I'm the one teaching.

[00:00:40]
So I've got the examples open, but let's say that you don't. There are a number of ways to go about doing it. One is to go to the file menu, find open, I have never done this. There's a lot of things we were talking about today, which is it's a thing that you can do that I have never done why?

[00:01:00]
Not totally sure it seems like a totally reasonable thing to do. The other option is you can go ahead and there is a ability if you hit Command-Shift-P or Control-Shift-P, because if I say Control or Command, if you are on Windows, swap it. Unless I'm very explicit that I really meant control.

[00:01:24]
Then we'll talk about later but we will talk a little bit more about the command palette in a second, but the command palette is your best friend. But there is something fun in here that if you have not done this before, you should definitely look at doing, which is this install code command in your path and this will install a little binary.

[00:01:45]
Well, it's technically already installed it'll put in your path. That will let you go navigate around your terminal, and then you can type code dot or code a given folder, and it will open that folder in VS Code. So like, anywhere you are on the command line, you can type in code dot for the current folder, if you wanna open a different folder, what have you so on and so forth.

[00:02:09]
We'll be doing both today, because, like, in the beginning, I'm just gonna start in the main repo. But like, as you can tell, if you download the repo, it's a bunch of little smaller projects. Sometimes we will laser focus into one of those and so we'll kind of navigate brigade up, down and around.

[00:02:22]
But I've already installed this otherwise, if that's not working for you for some reason, open will always also work. But like I said, 99.99999% of the time I will usually use the command line, navigate there and then open it in VS Code. But upon doing that, we should be welcomed by this beautiful, lovely, empty editor.

[00:02:50]
Some things probably need no introduction. Over here we have like the files in the directory, obviously a full file tree of everything in there. This is kind of the activity bar along the side where you'll see your file explorer, the ability to search across the entire project, some source control, this ability to run and debug things.

[00:03:15]
Extensions, and this is where it gets a little squirrelly which is depending on the extensions other stuff might appear here. Like we have some integration with various testing tools. In this case, I do have Github actions in here, Github Pull Request, and this little AI toolkit, which we'll talk about later, cuz that's very cool.

[00:03:33]
You've got a status bar down here, which will kind of show you the different kind of file type that you might be working with, as well as some other fun little things down here as well. When something turns bright red, pay attention to it but generally speaking, it's subtle for a reason.

[00:03:49]
If you ever forget the command palettes, keystroke, which is Command+Shift+P, which will probably get worn out on your keyboard by the end of day, you can also just click here too. One of the things I wanna point out, and we'll see this over and over and over and over again, is if anything has a key binding, you will see it in the command palette.

[00:04:15]
The practice that I want to instill in you right now is any time today, in the future, whenever, you catch yourself doing something somewhat tedious. Pause, hit Cmd+Shift+P, and just search to see if there's an option to do it a little bit easier. Maybe it has a key binding, maybe it doesn't, we'll figure out how to give it one if you want to so on and so forth, right?

[00:04:43]
Because we will talk about some of the keyboard shortcuts. I will tell you them, I will do stuff with my hands to make them happen on my screen. Will you memorize all of them the very first time I say a keyboard shortcut out loud? No right the kind of the best way to do it is to and again, install the habit right now, of like, if you catch yourself doing something where.

[00:05:11]
There's I think a lot of vim users want to talk about the fact that every time you reach for the mouse, it's like a drainage your productivity. I understand where my track pad is in relation to my keyboard that it's not that big a deal these days, but I think the idea is still there, right?

[00:05:25]
Because, like, if you find yourself, I wanna jump to other editor pane, or, I wanna jump over to search, or something along those lines, right? Now installing the like feeling of pausing, thinking about it, just even sometimes going into the command palette, because there's also, like a lot of little things that maybe you didn't even know were in there.

[00:05:45]
And some of them will only be important to you if you find yourself doing them right? The other way to find out some keystrokes sometimes is if you hover over stuff, sometimes they will be revealed to you right? So that's how you switch from the explorer to search is hovering over these various things and seeing what the various keyboard shortcuts are in this case.

[00:06:08]
But like I said, we've got like a little, there's a little folder in here called playground, which is a very, very exciting file. He says, thinking he understands alphabetical order. And there's some little stuff in here, we can put this back in a little bit but there are lots of little things.

[00:06:35]
>> Steve: You can say apple, carrot, grape, banana. You could select all these things unless I wanna sort them ascendingly, right? I could look up how to do that, I could do it by hand, or I can hit Command+Shift+P just type in sort and see I've got sort lines ascending, sort lines descending.

[00:07:00]
Great, awesome, pick that and it'll just do it. So anytime you find yourself pausing and thinking, stop, just type the thing into the command palette for a second, just see if it's there already. If not, we'll explore extensions, we'll talk about all sorts of other stuff and key bindings and snippets.

[00:07:16]
But step one, annoying thing that I was about to break my train of thought and stop thinking big brain thoughts to do, pause, Command, Shift, fee, see if there's an option, right? There's all sorts of things from like sorting lines to removing duplicates, so on and so forth.

[00:07:33]
So that's kind of the like subtle subconscious practice that we're gonna do through this entire time together, which is at any given point. And the nice part is, I think like an hour ago, Steve said something about I can split editor panes. I don't remember you just Command+shift+P and you type split, and there's the keyboard shortcut.

[00:07:56]
Or other options that maybe you didn't even know were there and some of them don't have keyboard shortcuts. And sometimes they have crazy ones like this, and I'll talk about what that means in a second, so on and so forth. But you can kind of see all of these kind of like fun things, like about like code folding and what level you want to fold everything to, so on and so forth.

[00:08:14]
Join lines great, anything you might need to do, pause, stop, Command+Shift view, or just click this thing up here, whatever. But if you find yourself clicking it, that's, again, the practice, learn the shortcut, right? You'll be happier, 'cause then like all of a sudden it becomes muscle memory and you find yourself standing in front of a podium trying to explain in words stuff that has become second nature to you.

[00:08:36]
And so that's kind of how you build it up as well.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now