# Best Sublime Text Features and Shortcuts (Mac)

## Метаданные

- **Канал:** Corey Schafer
- **YouTube:** https://www.youtube.com/watch?v=TB3qztdM7V8
- **Дата:** 09.08.2018
- **Длительность:** 19:09
- **Просмотры:** 25,138

## Описание

In this video, we will be learning about my favorite Sublime Text features and shortcuts for Mac OS. Knowing your way around your text editor will help you get things done much faster and be more productive. The features in this video have saved me a ton of time over the years. Let's get started...

Sublime Text Installation and Packages Video:
https://youtu.be/xFciV6Ew5r4


✅ Support My Channel Through Patreon:
https://www.patreon.com/coreyms

✅ Become a Channel Member:
https://www.youtube.com/channel/UCCezIgC97PvUuR4_gbFUs5g/join

✅ One-Time Contribution Through PayPal:
https://goo.gl/649HFY

✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey's Public Amazon Wishlist
http://a.co/inIyro1

✅ Equipment I Use and Books I Recommend:
https://www.amazon.com/shop/coreyschafer

▶️ You Can Find Me On:
My Website - http://coreyms.com/
My Second Channel - https://www.youtube.com/c/coreymschafer
Facebook - https://www.facebook.com/CoreyMSchafer
Twitter - https://twitter.com/CoreyMSchafer
Instagram - https://www.instagram.com/coreymschafer/

## Содержание

### [0:00](https://www.youtube.com/watch?v=TB3qztdM7V8) <Untitled Chapter 1>

hey there how's it going everybody in this video we'll be going over my favorite features and shortcuts and sublime text so sublime text as the editor that I use in most of my videos and I get tons of questions about how I'm doing certain things or what features I'm using so we'll cover my favorites here so learning how to use the features and shortcuts of the editor that you're using can definitely help you be more productive and get things done more quickly now this video will be for sublime text on the Mac OS X operating system so if you're on Windows then I have a video for that as well so I'll put a link to that in the description section below now what's going to do this as one single video but the shortcuts are so different between the operating systems that it was best just to split these into separate videos okay so the features that we're going to go over in this video will be features that will be available on the default installation of sublime text so you won't need any of the additional packages or anything else that I've installed with mine but if you're curious what packages and setup I'm using then I do have a separate video on that as well so I also put a link to that in the description section below also so with that said let's go ahead and get started so first of all the feature that I use most often and the one that I get asked about the most is the multi cursor functionality so I use this a lot in my videos to speed up certain things but I also use it all the time in my daily coding as well so this is also what will spend the most time one because there are a lot of different things that we can do with this now so for people who don't know what this is it's basically a way to have multiple cursors at once now at first that might not sound useful but let's see some examples and see why this is so awesome so I have a blank HTML file open here and let's say that we wanted to write some sample HTML code to put into a project so for example we'll create an unordered list with 10 different items so I'll create an unordered list by hitting ul and tab to complete that and now we want ten list items and let's say that within those list items we want each one to be an h1 tag so we could create one list item and then copy and paste that ten times or we can use multiple cursors to just type them all out at once so to do this I'm going to hit enter and make 10 blank lines so we already have one so two three four five six seven eight nine ten so now we have ten blank lines I'm just going to bring the cursor there to the beginning and now I'm going to create a new cursor on each line by clicking on the first line like I've done here and then holding down the command key and clicking on each spot where I want a new cursor so I'm going to hold down command and just click where I want these multiple cursors so you can see that it's creating a new cursor on each of these lines and once we have those cursors in place then we can just start typing and it will type that content in all of the cursor locations so if I want a list item then I can just type Li and hit tab and if I want an h1 tag now then I can hit type in h1 and hit tab and now let's put some text within that h1 tab so I'll save that so we can see how that typed out multiple lines for us all at once so using that command click is one way to get multiple cursors now another use case for this would be if we wanted to edit something in multiple places so for example let's say that we wanted to

### [3:09](https://www.youtube.com/watch?v=TB3qztdM7V8&t=189s) change all of the h1 tags in this list

change all of the h1 tags in this list to be h2 tags now you might be thinking that you can just do a standard find and replace all and in this example you could but a shortcut for that is to just click up here in the first h1 and then press control/command G and we can see that highlights all of our h1 tags for editing so then we could just edit all of those to be an h2 and save that so that changed all of the instances of the h1 tags but in a larger document you might have some h1 tags outside of this list that you don't want to change so simply highlighting and changing all of them might not be what we want so I'm gonna undo this and go back to h1 tags and save that and to get back to one cursor you can just do a regular click anywhere in the document so now let's say that we only want to change certain h1 tags so let's say that we want to

### [4:02](https://www.youtube.com/watch?v=TB3qztdM7V8&t=242s) change the last 5 h1 tags

change the last 5 h1 tags here to be h2s now one way you could do this is by clicking here where we want to start and then holding down command and just double clicking all of these instances that we want to change and that's creating multiple cursors at those locations but that takes a while there's actually a shortcut that we can use that will highlight the next match for us and create a new cursor so if I just select the first h1 that we want to change here and then press command D and then keep pressing command D until we highlight all of the

### [4:36](https://www.youtube.com/watch?v=TB3qztdM7V8&t=276s) highlight all of the h1 tags

h1 tags that we want to change so I hit command D until I hit the bottom of the document now if I kept hitting command D then it would loop around here to the top but that's not what we want right now so now we can change all of these bottom h1 tags by just highlighting all those using that command D and then changing those to h2s so we can see that we were able to use those multiple cursors to only change those where we want it okay now another awesome thing that we can do with multiple cursors is to copy and paste multiple things at once so what do I mean by that well for example I have a snippets file open here as well with some text on some different lines so we can see that we have 10 items here on 10 different lines so let's say that we want these items to be the text that is inside of our HTML list items so how could we do this well some people might just you know copy and paste these one at a time but that would take a really long time especially if our list was even larger than this so instead let's just highlight all of these at once and then copy and paste those so I'm going to hold in command and click at the end of each line like we saw before to

### [5:49](https://www.youtube.com/watch?v=TB3qztdM7V8&t=349s) create a cursor at the end of each of these lines

create a cursor at the end of each of these lines and now I'm going to highlight the text by holding in command shift and then using the left arrow and it should go all the way to the beginning of that text and now I'm going to copy that by pressing command C so now our 10 cursors here all copied those 10 different lines so now let's go back to our HTML list and now let's highlight the 10 locations that we want to change so to do that we can click in our text up here at the top that says test and then we can hold in command and press D all the way until we get all the way down here to the bottom and remember that command D creates a new cursor each time so now we have 10 cursors here all at the end of our sample text there so now that we have all 10 of those highlighted then we can simply paste in what we copied by pressing command V and we can see that it pastes in our 10 copied items into our ten different locations now when you copy and paste multiple items like this you have to have the same number of cursors that you use to copy in order to paste if you don't then it will paste all of the items and that can be pretty ugly so for example let me just show you what that would look like so I'm going to go down here to the bottom of the document and create a few

### [7:04](https://www.youtube.com/watch?v=TB3qztdM7V8&t=424s) create a few blank lines

blank lines here and I'm just going to create two cursors so I'm going to hold in command and create another cursor there so remember we have 10 items copied but now we only have two cursors so if I paste in with just two cursors then we can see that it pastes in all ten of our items in both of those spots so be on the lookout for that it might be what you wanted to do but it might not be so if you have 10 cursors like we did with our list then it will just paste one item per cursor like it did here in our HTML list so this multi cursor a copy and paste trick has saved me a ton of time more times than I can count it's really awesome once you get the hang of it now another thing that I use this multi cursor functionality for is to split things out and make them more readable so for example if I go over here to my snippets file and look down here at the bottom so this snippet is a real example of my path environment variable now if you don't know what that is then don't worry about it it's just basically a list of directories on your machine where your terminal looks for commands now all of these directories are currently separated by colons so that's not really readable right now especially if this was to contain a lot more directories than it currently does so let's say that I wanted to split these up on two different lines so that I could read this a little better so to do this I can simply highlight the first colon here and now I'm just going to hold in command and press D until I highlight the last colon so now we have multiple cursors here so to replace those colons with a new line I can just simply hit enter and we can see that now they're split up on two different lines and those being split up like that makes it a lot more readable okay so now that we saw a few examples of using this an HTML let's look at a quick example of how you might use this and Python so we'll just do a quick overview of the few things that we just now learned so I have a sample Python script opened up here so let me switch over to that so this is from my object Ornan video where we started learning about classes and manually setting attributes now this is an actual mistake that I made in that video so if you look here I created an employee one and an employee two and then I'm setting some attributes for both of those so I set some employee 1 attributes here and this is supposed to be where I'm setting employee two attributes but you can see that I accidentally set these on employee 1 again so all of these should actually be employee two so we could go through and manually fix these or we can

### [9:35](https://www.youtube.com/watch?v=TB3qztdM7V8&t=575s) use multi cursors

simply use multi cursors to just click on this employee one here and then press command D until we highlight all of the ones that we want to change now remember this isn't a global change we don't want to change all the employee ones just the Ford that we made a mistake with here so now that we have those multiple cursors then I can just come in here and do a backspace on the one and make that a two and now let's say that our boss tells us that this EMP variable name isn't descriptive enough and that we need to change it to something more descriptive so we want these EMP 1 and EMP 2 to actually be employee 1 an employee 2 spelled out so in this case since we want to change all of these then we can just highlight this EMP underscore here and then to just highlight all of these in the document then we can press ctrl command G and then change these to whatever we want so now that we have all of those highlighted then we can come in here and just type out employee ok so that's a look at the multi cursor functionality now that's by far my favorite feature and sublime text and this is also becoming more popular and other editors as well so even if you're not using sublime text then check if the editor that you are using has multi cursor functionality and start using it if it does because it'll save you a ton of time doing stuff like this ok so now let's look at some more features and shortcuts that I use a lot in sublime so one feature that I use all the time is switching between tabs and creating multiple panes so first of all we can see that we already have pull tabs open here with multiple files

### [11:10](https://www.youtube.com/watch?v=TB3qztdM7V8&t=670s) switch through these tabs

open so to switch through these tabs with a keyboard shortcut we can simply hold down command and option and then use the left and right arrows to switch through these tabs so that's how I'm switching through these tabs right now if we want to close a tab then we can press command + W and that will

### [11:28](https://www.youtube.com/watch?v=TB3qztdM7V8&t=688s) close down the tab

close down the tab now to reopen a closed tab if you open if you close that on accident then you can hit command shift + T and it'll reopen that closed tab so command W to close the tab and command shift T to reopen a close tab now if you're a chrome user then that should be familiar to you because it's the same keyboard shortcuts for Google Chrome and I'm glad that sublime text used those familiar shortcuts ok so now that we've looked at tabs now let's look

### [11:58](https://www.youtube.com/watch?v=TB3qztdM7V8&t=718s) set multiple panels

at how to set multiple panels now this is something that I use a lot especially when I'm doing something like web development where I want to be able to see the HTML and the CSS at the same time or maybe look at a Django or flask view and a template at the same time or anything like that so there are a lot of different panel layouts that we can use if we press command option + 2 then we

### [12:22](https://www.youtube.com/watch?v=TB3qztdM7V8&t=742s) open two panels side by side in a column

can see that it will open two panels side by side in a column layout and we can drag any tabs over here that we would like so that we can see these at the same time so now I have my snippets viewable over here as well as the Python code here now if we hold in command option + 3 then it'll open up three

### [12:42](https://www.youtube.com/watch?v=TB3qztdM7V8&t=762s) open up three columns side by side

columns side by side and we can drag the files here so that we can view three files at once so this is extremely useful if you're working on front-end code and you want to see your HTML Javascript and CSS all at once now if we press command option 4 then it'll open up four columns now I feel like this starts to get a little crowded and less practical but I guess if you had a very large monitor then maybe some would find it useful now if you press command option + 5 then it still opens only 4 panels but it'll split your 4 panels

### [13:19](https://www.youtube.com/watch?v=TB3qztdM7V8&t=799s) split your 4 panels into a grid

into a grid and I think this would be more practical on a larger monitor but I still don't use this often I mainly stick to the two panels or the three panels now if you prefer to stack them on top of each other rather than the side-by-side then you can hold in command option shift two and that will open up two rows instead

### [13:39](https://www.youtube.com/watch?v=TB3qztdM7V8&t=819s) open up two rows instead of two columns

of two columns so we can see here I have the Python on top and the HTML here on the bottom and the snippets tech tab is still down here at the bottom as well and if you ever just want to get back to a single window then you can do that by pressing command option + 1 and that'll take you back to the single window okay so another nice quick shortcut that I like is being able to move lines around using control command and then the up and down arrows so for example let me bring up the HTML here and let's say that we wanted to move a few of these items around so instead of copying and paste them in different places we can simply click on the line that we want to move so I'm going to move this bottom row here and it up to

### [14:21](https://www.youtube.com/watch?v=TB3qztdM7V8&t=861s) move it up to the top

row here and I'm going to move it up to the top so we can do this just by clicking on this line and then holding down control command and then using the up and down arrows to move this wherever we want it to go so if I move this all the way up to the top then we can see that was a lot easier than just copying and pasting it up there so let's say that we wanted to reverse this entire list so we could just put our cursor on these lines and then again that's control command and the up and down arrows so I can move the top item to the bottom and then these bottom items to the top and if we do this enough times then we can quickly switch that list around so that's a lot faster than just simply cutting and pasting all of those items just one at a time ok so the rest of these features are going to be really quick keyboard shortcuts so first of all in my videos I'll often run Python code using sublime text so sublime has a built in build system where it'll try to run the code of whatever language you are using so let me open up our Python code here and we can see that at the bottom we have this print statement where it prints out this employee ones email and the keyboard shortcut for running code is command and be and we can see that when we hit command B it prints out the email down here at the bottom now by default sublime will try to guess how you want to try to run certain code but if you're using different versions of Python or anything like that then I have a separate video on sublime build systems showing how you can set those up exactly how you want and if you ever want to get rid of this output down here then you can just press escape and it hides that window okay so another thing that I like to use a lot is whenever I've opened a directory is to get more screen space and collapse the sidebar

### [16:08](https://www.youtube.com/watch?v=TB3qztdM7V8&t=968s) collapse the sidebar

here so to collapse the sidebar we can hold down command and then press K and then B and we can see that collapsed that sidebar down now you want to be holding in command the whole time so if we want to open that back up again then we can hold down command and while holding that down we press K and then B and it opens that back up okay so something else I use a lot is the keyboard shortcut for commenting out code and to do that we can use the command ford slash shortcut and this works for multiple languages as well so over here in my HTML if I want to

### [16:43](https://www.youtube.com/watch?v=TB3qztdM7V8&t=1003s) comment out these last five list items

comment out these last five list items then I can just highlight those and press ctrl or command ford slash sorry then we can see a comments out those last five items if I come over here to the Python code then we can do this as well so if I just click on this line here and I wanted to comment that out then that is command Ford slash and that comments out that one line or we can highlight multiple lines and press command Ford slash and it comments out all of those lines that we had highlighted so we can see that the HTML and the Python both have different syntax and different ways of commenting their code and sublime adds those in correctly automatically for each language so that's extremely useful okay so lastly another one of my favorite features with sublime is the command palette now you can open the command palette by pressing command shift P and with the command palette open you can do a few different things like setting different syntaxes and things like that but the best thing that you can do is install new packages and packages allow you to add functionality that currently is in sublime so for example you may have noticed that my HTML has been Auto formatting throughout the video and that's an HTML package that auto formats your code for you and you can also install different packages that change the color schemes and the themes of sublime and things like that now I've already done a video on the packages and other Preferences that I have set in my sublime so I won't go into those details in this video but I will put a link to that video in the description section below if anyone is interested ok so I think that is gonna do it for this video hopefully you found this helpful and learned some new things about sublime text so I get a lot of comments asking about these features so hopefully that cleared up any questions that anyone would have now if you have any favorite features or shortcuts that I didn't mention in this video then feel free to leave a comment below and let me know about it now if you enjoy these tutorials and would like to support them then there are several ways you can do that these iasts ways to simply like the video and give it a thumbs up and also it's a huge help to share these videos with anyone who you think would find them useful and if you have the means you can cut your beat through patreon and there's a link to that page in the description section below be sure to subscribe for future videos and thank you all for watching

---
*Источник: https://ekstraktznaniy.ru/video/12217*