Unlimited WordPress themes, graphics, videos & courses! Unlimited asset downloads! From $16.50/m
by
FREELessons:34Length:2.5 hours

Next lesson playing in 5 seconds

Cancel
  • Overview
  • Transcript

2.4 The Command Palette

I'm going to create a new file, and on the Mac, I can do it with Cmd+N. And what that's going to do is create an empty tab, and notice that I can click on these tabs and move them around however I want. I can also right-click and have some additional options like close other tabs. So let's hit Cmd+S, or Ctrl+S on the Windows, to save, and we'll call it test.js. We're gonna create a test JavaScript file. Now, I want you to note that based on the extension, it will automatically set the syntax, which is fine. But let's say, for some reason, syntax to Markdown, something like that. So now we know, of course, that when we add our code, nope, it's not being highlighted correctly. So there's a couple of ways to change the syntax, and you'll find yourself doing this quite a bit. Again, you can come back down here and manually find the one that you want and switch it over to JavaScript, but a much better way is to use the Command Palette. If I go to Tools > Command Palette at the top. You'll see on the Mac, it's Shift+Cmd+P. Now, this is going to be one of your favorite features of Sublime. This is essentially replicating the entire menu bar within this box. And now we can use fuzzy searching to determine exactly what we want. So, for example, in this case, we want to change the syntax to JavaScript. Well, in this case, I would hit Shift+Cmd+P. And now I would type syntax, and now notice that it has all of the items that are available. So in this case, syntax, and I wanna set it to JavaScript, so I can type just a couple of those letters. And again, notice that it's fuzzy searching, and if you're not familiar with that term, fuzzy searching means I don't have to type the characters in order. It's just going to return all of the items where the letters that I type exist. So in this case, if I hit capital S, it's still going to make that available because we're using fuzzy searching. It found a j, it found an s, it found a t. But most of the time, Shift+Cmd+P, syntax JavaScript, and now we've instantly updated it and you can see there. Now, let's set the syntax back to Markdown just for a second. An easier way is, because we know we're using fuzzy searching, I don't really even need to type syntax. Shift+Cmd+T, JavaScript, done. Shift+Cmd+P, markdown, done, and that's a lot quicker. And this needs to be the cycle that you get into. Try to use the mouse as little as possible, and that's one of the keys to being superfast in your coding environment. Touch that mouse as little as humanly possible. And on that note, do keep in mind I'm going to be touching the mouse a lot more because I'm doing a course and I have to point these things out. But in my normal workflow, I very rarely touch it. So let's bring the Command Palette up once again, and you'll see in addition to showing all of the items that are available, it'll also give you some shortcuts. So if I type sidebar, you'll see that we have the option to toggle the sidebar. So now, that's an easy way when you wanna get rid of the sidebar, or in this case, bring it back. Shift+Cmd+P, sidebar, and now it's back. Now actually, in this case, this is one of the few keyboard shortcuts that I've remember, Cmd+K+B. Cmd+K+B, it's a toggle each time. Now, I say it's one of the few ones because I've learned over the years that there's only so many keyboard shortcuts that you can remember, and that's why a tool like this Command Palette is so powerful. I don't have to remember the odd shortcut to change the syntax, whether it's Shift+Ctrl+Cmd+S, I can't remember all of that. I can remember a few, but with the Command Palette, I can just look for the syntax. I can search for what I need. I need to change the sidebar. But of course, the ones that you use most frequently, like adjusting the sidebar, yeah, KB, that's an easy one to remember. So what I recommend is, when you bring this up, just try to commit some of these to memory. Anything that you would ever want to toggle, well, just type toggle, and now you can see all of the options. So, if you don't like the minimap here, we can look for minimap or toggle minimap. There it is, and now we've gotten rid of it, but I'm gonna bring that back because I like it. And that does it for this lesson. In the next one, I'm gonna show you how to very quickly go to any file on your project without even looking at the sidebar.

Back to the top