 It's no secret that Vim is one of my favorite applications that has ever been developed. And for good reason, Vim is amazing. It is by far the best text editor that has ever been designed. And I will argue to my own dying breath that that is true. I know that not everybody agrees with that, but for the sake of argument, let's just say that I'm right. I'm firmly of the belief that everyone, no matter their preference of text editor, should learn the basics of Vim. So things like colon WQ to quit, HJKL to move around, those sorts of things. But let's just say you've moved past that you know those things, but you want to learn a little bit more, you want to move to the next level, you want to become level two Vim user. What do you do today? What I'm going to do is take you through seven or eight really cool Vim commands that will take your Vim usage to the next level. So let's go ahead and do that. Let's just just jump right in. So the first thing that I want to teach you today is how to insert a character or word or something at the beginning of multiple lines. So it's really actually quite easy to insert something at the beginning of a line if it's just the one line. So line, it's really easy to do that. But let's just say you wanted to go through and uncomment a whole section of lines or you wanted to comment out a whole section of lines. You could just at every line enter a new hash mark just like this. That's really slow and cludgy, you know, it's not great, right? Let's just say you wanted to comment out a whole section of lines. So first, let me uncomment all these things. So I'm going to hit control V in order to go into visual block mode, go all the way down and then hit D for delete. Now we have all those things uncommented. So let's just say I wanted to re-comment them, but I didn't want to just do an undo. I mean, never be cheating. Instead, I want to actually do this the way I want to teach you. So in order to do this, you first, you want to get into visual block mode, that's control V, and then you use your them keys or your arrow keys if you still have them enabled to go down to the last line that you want to comment out. And then you want to hit shift I, type in the thing that you want to put in at the beginning of the line. So in this case, we want to use a hash mark and then hit escape. And now all of those lines are now commented out just like they were before. And that you can do that with literally anything. So if you have, if we go down here at the bottom of the file here and we have all these lines here, let's just say I wanted to comment all these things out, I would go into visual block mode, first make sure you're at the beginning of the line. So zero to go to the beginning of the line, visual block mode, control V, scroll down, and then shift I, hash mark, escape. And now all that stuff that I highlighted is now uncommented. Now the next one that I want to cover just real quick, let's just say you commented out something my mistake, or you didn't want to do the things you just did, you'd undo control R to redo real simple, right? There's not anything there that is overly complicated, you'd undo control R to redo. Okay, so the next one is probably one of the most important things you'll ever learn about them. And that is to search and replace. Now I say it's the most important thing simply because as you get into working with longer and longer files, there's a lot better chance of you having to actually replace words throughout the entire file, like it's the longer you've used them, the more likely you are to have to do this. So in order to actually search and place, replace something, it's really easy. So down here at the bottom, you'll see where I'm typing this in down here where the cursor is. So we'll do colon, in order to get into command mode, s, or excuse me, colon, percent s, and then slash, and then the word that we want to replace. So in this case, let's just do easy list. And you can see how I have it set up to actually highlight what we've just typed. Do another slash. And the next thing you want to type in is what you want to replace that word with. So in this case, we want to replace it with hello, and then another slash. Now if you just hit enter here, or I believe before the slash, it would just replace the first instance of whatever you're searching for. So if you just want to replace the first instance, you could do that. Now what we would really don't want to do that, that's not really all that useful. You could just then change that word if you wanted to. Instead, we're going to use the G modifier, and that will actually replace every instance of easy list with the word hello. Now let's just say you're not quite sure if you want every single instance of that word to be replaced. If you add the words letter C to this command, so slash GC, when you hit enter, it'll ask you every single, for every single instance of that replacement, if you are sure you want to go through with the replacement. So you can hit yes or no, and then it will move on to the next one, and so on and so forth. It's really quite powerful because it allows you to replace words throughout an entire document without having to do them one at a time. But if there are certain instances where you don't want to replace, you can use the confirmation option as well. So I'm going to actually cancel this and get rid of the search. So the next thing I want to teach you is how to indent something. So let's just say we have these three lines here. We're going to go back to the beginning of the lines, and let's just say we wanted to indent them. So in order to do that, we get into visual mode. So we hit V, or capital V, either one works, and we highlight those three lines. And then if we want to insert them, we do shift and then the chevron. So we do the, I believe that is the less than sign, maybe the greater than sign. I never remember which those are. It's the one pointing that direction, that direction. If we wanted to do the opposite, say these are already indented, again, the highlight them and then shift the left facing chevron if that's what that's called. I don't even remember. Like I said, I'm horrible with those names. I've learned them over and over again. Like every single time I do something that requires the use of those later greater than or less than signs, someone in the comments will say, Hey, Matt, this is how you do it. This is how you remember. I'm just too much of a dumb ass to remember it. So don't try to teach me. I'm never going to remember. Anyways, the point is that's how you indent something really easy. Highlight and then that okay, so that is indentation. So we've already covered earlier on do and redo. The next thing I want to show you, let's just say you wanted to go to a certain line number. This one's really easy. If you want to say you want to go to line number 59, so you could do colon type in 59 enter, it'll take you to line 59 really easy. And this is great for if you have a file that is really, really long, but you know exactly where you need to go, or even their bouts, you can type in the number of the line number, even if you don't use line numbers, because chances are down here at the bottom underneath my face, you'll see actually says line 59 here. So even if you don't use line numbers here along the side, you can still use colon line number to get to the exact line number you want to do now. The next one is really fun. So let's just say you don't use something like nerd tree, like I do. Nerd tree is basically a file manager right inside of them. It's a plugin. I prefer it because it can go up along the side and it's more stylized than the built in file manager. But then like I said, does have a built in file manager, let's just say you wanted to use it. So how would you do that? You could get into it the old fashioned way by doing colon explore. And that would come up like that. It's not great because it literally takes up the entire screen, like you no longer have access to what you're working on. And chances are you weren't actually looking to open up a file. You just wanted to see the location of something. Or you wanted to see what the name of something was. But you no longer have access to the thing that you're working on. So if we get out of this, the great thing about the Vim Explorer is you can open it up in a split. So if we do colon, and this is fun, capital S E X, this will open up a split for the explorer. And as you can see, we still have the file we were working on. And the explorer is here. And you navigate this just like you would with them with the Vim keys. And if you wanted to go into a file, you hit enter. And then you could use these here to go up level and so on and so forth. And then you can quit out of that just by you doing colon or you do shift ZQ. If you don't want the horizontal splits, you can do a vertical split by going colon S E X exclamation point. And I'll bring up the explorer along the right side or the left side in a vertical split. So that is also really cool. So that is the built in file explorer for them. Now the last one on the list that I find very, very useful is the ability for them to go to files that have passed listed out in the file you're in. So as convoluted as that sounded, it's actually fairly simple. So I have these three file paths here. And traditionally, if I wanted to actually go to one of those file paths, if I wanted to go one of those files, I'd have to either go into the file explorer and then go to that file, or I'd have to exit of them, navigate to the file, open up them again. But them actually has this built in. So if I do G F, I go to that file. Now let me show you that again. So let's just go to a different one. So I want to go to the theme my theme folder, my three, my theme file, G F takes me to my theme file. That is as simple as it is. So those are the absolutely essential them commands that I wanted to teach you today. There are the thing about them is that I could have gone on for another 40 or 50 commands. And I do plan on doing another extravaganza of them commands here in the future. But those videos are really, really hard to do because they just take forever. I think the last one took me like an hour and a half to actually record. So that's in the future. This one here was just an easy thing where I tried to tell you a few commands that I just consider absolutely essential that I think that everyone should know that will take your Vim usage to another level. If you have really cool Vim commands that you'd like to share, leave those in the comment section below. I'd love to hear them. You can follow me on Twitter at Linuxcast. You can support me on Patreon at patreon.com slash Linuxcast. Before I go, I'd like to take a moment to thank my current patrons, Robert Sid, Devon Patrick, Fred Kramer, Megwin Jackson, I have tools, Steve A. Seperick Lennox, Garrett, Samuel Mitchell, ArtCenter, CarbonData, Jeremy Sean, Odin, Martin E. Bled, Andy Ross, Merritt, Cam Josh, Jolie, Daydog, Peter A. Cruisifull, Derek Bennett, Six and Primus. Thanks everyone for watching. I'll see you next time.