Best Sublime Text Features and Shortcuts (Windows)
18:59

Best Sublime Text Features and Shortcuts (Windows)

Corey Schafer 09.08.2018 32 828 просмотров 773 лайков

Machine-readable: Markdown · JSON API · Site index

Поделиться Telegram VK Бот
Транскрипт Скачать .md
Анализ с AI
Описание видео
In this video, we will be learning about my favorite Sublime Text features and shortcuts for Windows. 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/

Оглавление (14 сегментов)

Intro

hey there how's it goin everybody in this video we're going to be going over my favorite features and shortcuts in sublime text so sublime text is 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 now 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 Windows operating system now if you're on a Mac then I do have a video for that as well so I'll put a link to that in the description section below I was gonna try to do this as one single video but the shortcuts are so different for each operating system that it was best just to split those 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 packages that I have installed with my installation but if you are curious about what packages and setup I'm using then I do have a separate video on that as well so I'll also put a link to that in the description section below also so with

MultiCursors

that said let's go ahead and get started so first of all the feature that I use the most and the one that I get asked about the most is the multi cursor functionality so I use this in a lot of my videos to speed up certain things but I use it all the time and my daily coding as well so this is also what will spend the most time one because there are a lot of different ways to use this so for people who don't know what this is it's a way to have multiple cursors at once now at first that might not sound useful but let's look at some examples and see why this is so awesome so I have a blank HTML file open here so let's say that we wanted to write some sample HTML code to put into a project so for example we're just going to create an unordered list with ten different items so I'm gonna create an unread list by hitting ul and then hitting tab and now we want ten list items and let's say that within those list items we wanted each one to be an h1 tag so we could just create one list item and then copy and paste that 10 times or we can use multiple cursors to just type them all at once so to do this I'm gonna hit enter and make 10 blank lines here so we already have one line so I'll make nine more 1 4 5 6 7 8 9 ok so now we have 10 blank lines and now I'll create a new cursor on each by clicking on the first line here and I'm just going to make sure that that's untapped and now I'm going to hold down control and just click on each spot that I want another cursor so I'm holding down control and just clicking on these other lines and you can see that it's creating multiple cursors here and once

Typing

we have those cursors in place that we could just start typing and it will type that content in all of those cursor locations so if I type out a list item so li and then hit tab creates the list item and now I can create an h1 tag by hitting h1 and pressing tab and that completes that and now I can just fill this in with some dummy text so I'll just put tests there okay so now you can see that we have ten list items fully complete so we can see that it just typed out multiple lines for us at once so using that ctrl-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 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 fine and replace all and in this example you could but a shortcut for this if I just select the first h1 here if I have my cursor here within the first h1 and then hand hit alt f3 then you can see that

Editing

highlights all of our h1 tags for editing so now we can just simply change those to h2 and save that so that changes all of the instances of the h1 tags but in a larger document you might have some other h1 tags outside of this list that you don't want to change so simply highlighting and changing all of them might not be exactly what you want so let's change these back to h1 so I'm just going to undo that change so now let's look at an example we're going to want to be a little more selective so let's say that we just want to change certain h1 tags so let's change the last 5 h1 tags to be h2 tags now one way that we could do this would be by clicking where we want to start so that would be right here and then just holding down ctrl and double clicking all of these instances that we want to change but going through and clicking like that might take a while and there's actually a shortcut that we can use that will highlight the next match for us so if I just click the first one here now our cursor is within that h1 tag and now let's just hit control D and then keep hitting ctrl D and it'll highlight the next h1 so whatever you have highlighted hitting control D will highlight that next match for you so that you can make multiple changes at once so now we went all the way to the bottom here if I was to hit control D again then it would cycle back up to the top but we don't want to do that so now I'm just going to change those last five to h2 tags so we can see that we can use those multiple cursors to only change those where we want 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 and let me open this up it's got a few different lines and we can see that we have ten items here on different lists 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 copy and paste one item at a time back and forth but that would take

Highlight Paste

a really long time especially if our list was a lot larger so instead let's just highlight all of these at once and then copy those and paste them so I'm going to do a ctrl click at the end of each of these lines which we saw before will create a cursor at the end of each of these lines so I'm just going through and control clicking down on each of these items and now I'm going to highlight all of this by holding in control shift and then hitting my left arrow and I'm just going to do that multiple times until I get back to the beginning of the line and now once we have everything highlighted let's copy this by hitting ctrl C and now going back to our HTML and now back in our list let's highlight the 10 locations that we want to change and I'll do that just by clicking on the first test here and then pressing ctrl D like we did before and just highlight all of these so I will just highlight down all the way to the bottom and now that we have all 10 of these highlighted then we can simply paste in what we copied by

Paste

pressing control V so you can see that it pastes in all of that information into those 10 locations so that pays our 10 copied items into ten different locations now when you copy and paste multiple items like this you have to have the same number of cursors that you used to copy in order to paste so if you don't then it will paste in all of those items and that can be pretty ugly so what I mean by that let me just show you what I mean so I'll come down here to the bottom and create a few blank lines here now I'm going to just create two cursors now remember we have 10 items copied but only two cursors here so now if I paste this in then it's just going to paste all 10 of those items on those two cursors so be on the lookout for that maybe that's what you want but maybe it's not so if you have 10 cursors then it's just gonna paste all 10 of those items one time just like it did up here in our list so now I will remove that and go back to our list here so this multi cursor copy and paste trick has saved me a ton of time more times than I can count so it's pretty awesome now another thing that I use this for is to split things out and make them more readable so for example let me go back to my snippets file here if I scroll down here to the bottom so this is a real example of what my path environment variable looks like on my Mac and Linux machines now if you don't know what this 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 separated by colons so that's not really readable right now especially if you have a lot more directories how to do it than this so let's say that I wanted to split these up onto different lines so that I could read this a little better so to do this I can just simply highlight the first colon here and now I'm just going to press control D until I highlight all the way up until the last colon and now I'm just going to simply hit enter and we can see that it replaced all of those colons with a new line and split all of these directories up onto their own lines then and that makes it a lot more readable ok so now that we saw a few examples of using this in 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 a few tricks that we just learned so I have a Python script opened up here so let me switch to that so this script here is from my abs Oriented video where we started learning about classes and manually setting attributes now this is actually a mistake that I made in that video so if you look here then I created my employee one object and an employee two object and then I'm manually setting attributes on both of those here now for the second group of attributes here I accidentally set them on employee one again so all of these actually should be employee two here so we could go through and manually fix those or we can simply use multi cursors to just click on employee one here at the top then press control D

Multi cursors

until we highlight the four that we want to change now remember we don't want to change all of the employee ones just the ones in the second group so that's why control D is so useful once we have all those highlighted then we can just go to the end here delete that one make that a to save it and we're done okay and now let's say that our boss comes in and tells us that this EMP one variable name isn't descriptive enough so we need to change that to something more descriptive so we want to change EMP one and EMP to be employee one and employee two and in this case since we want to change them all then we can simply highlight one of these here so I'll just highlight the top one and then I will press alt and then f3 to highlight all of those EMP variable names and to change all of them all at once I will just go to where we want to make the addition and type that in and you can see it's typing at all of those cursor locations and changing them all and then we can save that so now we can see that all of those were changed okay

Switching between tabs

so that is a look at the multi cursor functionality in sublime text now that is by far my favorite feature in sublime now this is also becoming more popular and other editors as well so 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 you can because it'll save you a ton of time okay so now let's look at some more features and shortcuts that I use a lot within 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 multiple tabs open here with multiple files open so to switch through these with a keyboard shortcut we can use ctrl tab and ctrl tab will move to the next tab and ctrl shift previous tab now if we want to close a tab then we can hit ctrl W and we can see that club that tab that we're on closed down now if we accidentally closed the tab and we want to reopen a closed tab then we can hit control shift T and it will reopen the tab that we closed now if any of you are Google Chrome users then that should be familiar to you because it's the same keyboard shortcuts for Chrome tabs also and I'm glad that sublime uses those familiar shortcuts ok so now that we've looked at tabs now let's look at how to set up multiple panels now this is something that I also use a lot especially when I'm doing something like web development where I want to be able to see the HTML and CSS at the same time or maybe you know 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 so if we hit alt shift and 2 then we can see that it creates and opens two panels side by side and a column layout and we can drag any tab that we want into this panel so that we can see both of these at once so now I can see the HTML file here along with the snippets file here

Column layout

now if we hit alt shift and 3 then it'll open up 3 panels in a column layout and then we can look at three files at once now with the word wrap here and the text so large it's getting all scrunched together but usually I have two text a lot smaller than this so this three column layout is extremely useful if you're working on something like front-end code and you want to see your HTML Javascript and CSS all at the same time ok now we can also hit alt shift and 4 and that will open up four columns now I feel like this starts to get a little crowded and a little less practical unless you have a really big monitor but some people find it useful now we can also hit alt shift and five and it will split our four panels into a grid so instead of that four column layout now we have two columns and two rose now I feel like this would be a little more practical on a large monitor but still I don't really use the four panels very often I use the two panels a lot and the three panels a little bit also now we can also hit alt shift eight and that'll just open up two rows if you prefer them stacked one on top of another rather than side by side and to get back to our single window then we can simply just hit alt shift and one and it'll take us back to that single window okay so another nice quick shortcut that I like in sublime text is being able to move lines around using ctrl shift and then the up and down arrows so let me show you this by going back to our sample HTML here so let's say that we wanted to move a few of these items around so instead of copying and pasting them all around we can simply click on the line that we want to move and then hold in ctrl shift and then use the up and down arrows to move this around where we want so we can see I'm moving it up to the top of the list now and if I hit the down there it moves it to the bottom so if we wanted to reverse this whole list then I could simply click on the first item and hold ctrl shift use the arrows to move it

Run Python code

down and then just do this for every item in the list and pretty soon we will have the whole thing reversed and then switch the five and six and that reversed our list so that would have taken a lot longer if we were to copy and paste everything okay so the rest of these features that we're going to look at are just going to be real quick keyboard shortcuts so first of all in my videos I'll often run a Python code using sublime text so sublime has some built in build systems where it will try to run the code of whatever language you're using so let me open up my sandbox Python file here and I will close that and we can see that we have a print statement here at the bottom of the file so the keyboard shortcut for running code in sublime text is control B so if I press control B then we can see that it runs that code and prints out that first employees email now by default sublime will try to guess how you want to run certain code but if

Collapse sidebar

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 okay so another thing that I do a lot when I've opened a directory is to get some more screen space and collapse the sidebar so first of all let me close this bottom panel here where we ran our code and to do that we just press escape and now I want to collapse this sidebar to get more screen space so to collapse that I can just hold down ctrl and then press K and then B and you want to hold down control the whole time when you're pressing both of those buttons so again I'm gonna hold down control and open this sidebar again and then press K and then B while holding down control and it opens that back up so that's a nice quick keyboard shortcut to collapse that and pull it back up when you want it okay so something else that I use a lot is the keyboard shortcut for commenting code and to do that you can use control forward slash and this works for multiple languages as well so over here

Multiple languages

in my HTML if I want to comment out these last five items here then I can just highlight those then press control Ford slash and we can see that it comments out those last five items there and if I want to do this in Python then I can come in and click on a line and press control Ford slash and it will comment out one line or I can highlight multiple lines press control Ford slash and it comments out all of those lines at once so we can see that the syntax for comments and HTML and Python both have different ways of commenting their code and sublime adds those in correctly automatically for each language so that's really 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 ctrl shift P and that will open up the command palette now the command palette allows you to do a few different things like setting different syntaxes and

Packages

things like that but the best thing that you can do is install new packages and packages allow you to add functionality that currently isn't in sublime so for example you may have noticed that my HTML has been Auto formatting throughout the video and that is an HTML package that or match your code for you and you can also install packages that make visual changes as well so it gives you different color schemes and different themes and things like that also now I've already done a video on the packages and other preferences that I have set in my sublime text so I won't go into details in this video but I will put a link to that video in the description section below if anyone is interested okay so I think that is gonna do it for this video hopefully you found this helpful and learn some new things about sublime text I get a lot of comments asking about these features so hopefully this 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 and let me know about it so if you enjoy these tutorials and would like to

Outro

support them then there are several ways you can do that the easiest 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 contribute through patreon and there's a link to that page and it's scripts in section below be sure to subscribe for future videos and thank you all for watching

Другие видео автора — Corey Schafer

Ctrl+V

Экстракт Знаний в Telegram

Экстракты и дистилляты из лучших YouTube-каналов — сразу после публикации.

Подписаться

Дайджест Экстрактов

Лучшие методички за неделю — каждый понедельник