 What's up guys vim diesel here today? We're gonna do something a little different. In fact, I'm thinking about doing a vim or vim Tudor let's play slash commentary. I'm just gonna go through vim Tudor, but importantly, I'm gonna give you my commentary I'm going I'm returning to vim Tudor after Years and years because there are all these people who watch my channel. I want to learn vim I want to learn to them all you got to do is type in vim Tudor in your command line But I think there are a lot of little things that I want to add to vim Tudor So we're just gonna go through it. I know you zoomers love let's plays. So that's what we're gonna do All right, so I'm gonna start off just type in vim Tudor in your command line and bring it up here All right, vim Tudor vims very powerful editor blah blah blah Stuff like that. Oh wait, I'm okay. I got to play stupid. I got to play like I don't know what I'm doing in vim Okay, so we'll read now make sure that your caps lock key is not depressed and Press the J key enough times to move the cursor to 1.1. All right, so 1.1 What's 1.1 on it's on moving your cursor now vim, of course, actually I'll turn on the screen key so you can see what I'm pressing but So vim H J K L. They are your direction. So K is up J is down L is right H is left so notably you can go through any of these lines notice that on lines where there's no content if I go here and press L Obviously, I'm not going. There's no like words out there to go to so it doesn't unless you have white space So anywhere that's basic movement. I know I you know a crit I cringe because I know in history There has been some gamer who has started to learn them and he's like I should change these to be lost Just so annoying. All right, so most important thing exiting vim This is all right The thing that annoys me most is soy devs who don't know vim and like constantly brag about how they don't know it And how they can't exit it. All right It's just such an annoying joke and frankly most of these guys probably actually know how to use them But they're just being stupid. It's just annoys me. Anyway, so the way they tell you is actually the dumb way to exit vim Okay, so they say first you got to press escape to make sure you're a normal mode Of course, if you're new to vim, you don't even know know what normal mode is But we press the scape and they say press colon colon q Exclamation point and then press enter. All right, so we're out. That is the heart That's the most annoying way to quit vim. All right, that's a stupid way to quit vim How you oh, yeah, so control D is go down half a page control you is go up half a page You know D and you up and down But anyway, so this is like the dumbest way to exit vim because it's way too many I mean you've got to press first off colon that's hold down shift and press something q is over there Hold down shift and press. No, it's just stupid. That's a waste. Here's the real way to exit vim The real way to exit vim is hold down shift And press capital Z pack capital Q. You're out. That's the real way to exit vim capital Z capital Q that's it or Now capital Z capital Q is force quit like exit and don't save any changes If you do make changes anyone to save them press capital Z capital Z. That's the real way to exit vim I don't know why people whenever I see someone using like colon q to exit. It's like that's that's way too hard I don't know. It's so much more ergonomic. It might not sound that much more ergonomic But it's just like right, you know, you get one-handed. It's like no problem. Anyway, that's how you actually actually exit vim unless you want to do something like You know, we'll say kill all Vim, okay, that's another alternative. Oh wait, I guess that doesn't really work. Does it? All right, whatever who cares? Okay, exiting vim. So Line number three or lesson number 1.3 had to delete stuff. So we're deleting stuff with X No one delete stuff with X. It's the most I don't know why they're telling you this But all right, this is just practice to get you moving around So press X to delete the character under the cursor move the cursor to the line below marked. Okay Wait, all right. Yeah. Okay. So to fix the characters Uh, move until the cursor is blah blah blah Uh, so we're just going to delete the characters we don't need I'm gonna do it the dumb way To get rid of that cal jumped over The Moon man, it's so hard to use vim this way now, of course if you're a newbie vim user You're like wow, you got to press so many keys to delete stuff No, this is like this is like the dumb way to use vim, but you got to look you got to start somewhere You got to learn this Um, so anyway, oh, what did I just do? So zz. All right. Here's here's a vim lesson for you vim noobs Let's say you're on this line I if I press zz See how I'm on the line that says press X to delete blah blah blah if I press lowercase z lowercase z Don't hold down shift as you know, that's exit But lowercase z lowercase z that puts that line in the middle or if you say lowercase z and then t that puts it at the top or Is it zb for bottom? Yeah. Okay. All right, so that that's a pretty useful command. I use zz a lot I you know, I've never really thought that that's the same key as it is to like save and quit but Uh, I I've never missed. I mean you don't accidentally hit shift. So it's not really a problem All right, so that's deletion press X to delete again. You don't actually ever do that In vim you'll be using d and uh, you know motions to delete stuff Okay, so press I to insert move the cursor to the first line Uh below marked Uh period To make the first little blah blah blah. All right. So here's what we're gonna do. We're going to Go here. We're gonna go to our period here. We're gonna press I and we're gonna say Uh, wait. Oh, we're missing some here too. We're gonna go here. There is some text Missing oops did it the dumb way didn't I? from This line Okay, so the only things we really know how to do the vim tutors has taught us is hjkl I to go into insert mode, right and so insert mode just to be clear What's the difference between insert mode and normal mode? Well insert mode is just like normal typing As it is in any other kind of program, right? Whereas normal mode is every single button In vim is a shortcut to something. That's the magic of them. Maybe I should have said that beforehand But this is the most important point about vim this whole thing normally see a normal normal. I shouldn't even say that a Normie text editor. These are just like buttons that type stuff No, in vim there are buttons that types type stuff in insert mode But in normal mode there are actually every single one of them is a shortcut that does something special and unique That's the magical thing about vim. It's like turning your computer It's like taking your keyboard and making it like a control console You have all these superpowers. You just got to learn them. All right So I to go into insert mode you type whatever you want when you're done typing stuff you press escape Now first off this is should be basic vim stuff. All right. This is something you got to do when you start vim Um pressing escape is hard It's way too far like when you're constantly typing stuff and then having to go to escape to go to normal mode No, that's too hard. So Caps lock just map it look up how to map it on you know linux or i don't know maybe some of you guys are using mac But look up how to remap caps lock Or switch escape and caps lock. That's what you want because caps lock useless key in a great location Change it to escape. It's actually very useful even outside of vim, but in vim you're definitely going to want to have it Okay. All right. So basic stuff Zz again, actually let's do zt So less than 1.5 Uh A pending. Oh, I was gonna say, okay. Here's something I should say Um, you may notice if I press hjk and l I'm moving really fast If you hold down k on your machine, you're probably going to be moving slower than me Why is that? Well, the reason that is let me show it to you. I have a little script Called remaps. Okay, this this script runs when I start up my machine One of this and so, you know, I don't know what you're using what distribution you're using But just you can put this command in your Uh as a startup script and it will change your life and it's this command right here. Okay It changes like the x rate. It basically is the rate where, you know, if you hold down a key If it's going to rep, you know, keep pressing it over and over again because by default It's you know, it's going to be something like actually maybe I can I don't know what the default is. Let's say, uh 100 Let's see if that changes. I don't know if it actually. Oh, no. Oh, that seems even faster. Okay. Let me Let's see x rate, uh What? Oh, wow. Now I can't even type. All right, go back. Oh, go go back, please. All right. No. Oh, man Okay, yeah, that was too fast. I'm not even going to experiment with that But just know this particular command x set r rate 350 that works perfectly for me It just speeds things up just a little bit. So it's a little faster moving around now, of course the vim pros They'll be like, I just like to interject for a moment. You shouldn't be using hjkl to move around You should be using there are many other bonds to move around more effectively and vim. I'll probably talk about those later But having this does not hurt. I do recommend it And I'm you know, if you have it, it's easier to get around with more basic stuff like hj and knl Just you know to go ahead and tell you some other ways you can move around. Let's say, um, Curly brackets. So if you hold shift and press the curly, I mean curly brackets on at least american keyboards there You hold down shift and press the key with them But they move you see if I press, you know, left curly bracket it moves up by an entire paragraph It's like skipping between paragraphs. That's one example of how to move around And I gave you the one earlier of control u and control d to move up half a page or whatever Um, yes, I know I'm throwing a lot of stuff at you But you know, you can you can watch the video multiple times if you need I don't know I'm just sort of add living it. Okay, so Let's see Let's add some more. Oh, yes a pending. This is some good stuff So we learned that I puts you an insert mode and you can type stuff in. Okay Also, there's capital a and capital a it automatic It puts you an insert mode and it puts you an insert mode at the end of the line Notice specifically oops, I'm redoing stuff. Oh, we haven't learned how to redo or undo stuff. I shouldn't be doing that But even if you're at the beginning of the line here, if you press capital a now you're at the end Now you can type in the end of this line same thing here Okay, perfect So vim tutor doesn't notice it So these are two ways to go into insert mode i and capital a but you can actually use capital i And lowercase a as well. There's there's actually a systematic Change between them now notice this. Okay. Here's what I'm going to do Notice my cursor right now is on the t the first t in text If I press i right here and start typing that is going to that's inserting stuff to the left of that t Okay Now I'm going to undo that change now. Let's say instead of pressing i I press lowercase a That puts me in insert mode, but now I'm actually instead of on the left side of t I'm on the right side of t. So if I type it's going to be inserting stuff on the right side of t That's the difference between so i is inserting on the left Uh lowercase i and lowercase a is inserting on the right side, right? That's the very subtle difference That'll come up But capital i and capital a are just extreme varieties So lowercase a inserts right to the right Capital a goes all the way to the end of the line all the way to the rightmost side and then you insert stuff That's the logic behind it. Whereas. What do you think capital i does? Well, capital i puts you at the very beginning wherever you are And allows you to insert stuff. Okay, so you inserted some text blah blah blah. That's it All right, so very useful command. So you now know four ways to go into insert mode There are probably other ones that i'm not immediately. Oh, yeah, there are lots of it like well, we'll talk about some of those later Okay, so editing the file so use wq to save and edit exit So you learn that you know colon q Especially colon q exclamation point is exit, right exclamation point just means force it. Don't you know confirm or don't you know I actually want you to do it But so if you add in a w here, so if you say wq that means save and quit I've never used this because Um an equivalent of this. I don't know if they actually say that this here But an equivalent of that is just using x and you can use it with an exclamation point as well That saves and quits now in vim tutor. It's not going to matter if you save and quit because uh, you know, it's not going to um It doesn't change like you're using a temporary file here So the changes i'm made in this are not persistent if i actually change it But anyway, anyway, so appending editing a file Okay, yeah, so you now know how to save saving in general if you just want to save when you're in vim That's just colon w and that's it or you know exclamation point Yeah, if you want to force it, but anyway and forcing is important. Let's say you're You're stupidly modifying a file in two places That might be a time to force save You really shouldn't do that or I think you can do I don't even know But there's if it's like a read-only file or stuff it'll prompt you for that Okay, so lesson one summary we now know basic stuff about vim and i've thrown in some important tips So, you know hjkl, okay, you know how to quit. That's just with q You know how to save that is with w and q or just saving alone And this is like colon and then w blah blah blah Just in case you don't know Vim has many many commands, you know colon commands When you press colon you're basically just going to the place where you can You know the Insert any kind of arbitrary vim command. Uh just as an example Let's here's an example of a command that I really I don't know Here's an example. I'm going to highlight this entire document. We haven't talked about that yet and I'm going to say I'm going to have press colon to get into the command mode and I'm going to say Sort Okay, what did that do? Well, it actually just sorted every single line in this file so now It's sorted every line alphabetically Of course, you don't really see that it's alphabetical because most of these lines don't start with stuff But you can see here, right? It is we've just highlighted everything and we ran a vim command It happened to be sort that sorted everything Other vim commands are q to quit or w to write a file, but uh, anyway Now let me find where we were Wq okay Okie dokie and you now know how to use i and capital a to go into insert mode I also talked about you know Capital i which goes to the beginning to the beginning of the line and lowercase a which is just sort of goes to the right Um, all right. So lesson two deletion commands now Of course using x to delete as they brought up totally useless. No one ever Okay, I use it every once in a while, but really you use D to delete now the magic of them here's where the magic of them is going to start. Okay So I maybe I'll read this press escape to make sure you're in normal mode Use the cursor blah blah blah move the cursor to the beginning of a word blah blah blah Okay, there so now i'm on this line I'm going to say there are it says there are some Words fun that don't belong paper in this sentence. So we're going to go We're going to go to the words that don't belong and they tell us to delete a word you say d And then w for word you you have to be at the very beginning of it So d and then w that don't belong Paper in this sentence. Okay. So now we have cleaned up the sentence now, of course Should I go into this now? I don't know. Well, I'll talk about it in a second Okay, so we've now learned how to delete a word So x is just delete a character If you say d that's it's really sort of like a vim function d is a vim function You're telling it telling it. I want you delete to delete something and the next thing you press is going to determine what you delete Basically, all right So more deletion commands all of these are going to start with d It's really again. It's just d and then you tell it what to delete So type d and then the dollar sign to delete all the way to the end of the line So here's our example sentence someone type the end of this line twice end of this line twice So we go here to the part we want to start our deletion at and we say d and then dollar sign Now y dollar sign if you know regular expressions You know where this is going because dollar sign is a symbol of the end of the line In the same way that the little carrot thing is a sign a sign of the beginning of the line Now here's another motion command Um, you don't have to say if you just want to move to a different part of the line You can actually just press a dollar sign to go to the end or you can press You know zero to go to the beginning of the line. Actually, you know, I never really thought about it Can you actually use the carrot? Yeah, you can use the carrot to go to the beginning of the line and vim The regular expressions in vim they sort of work together I guess there are people who don't know what regular expressions are but just play along if you don't So anyway, so d dollar sign deletes all the way to the end of the line, but That's a lot of key presses. I've always thought that's a lot of key presses There's a secret There's a secret is the secret is you can actually just press capital d. That does the exact same thing It's just like a little shortcut. You can just press capital d. That's nice It's nicer than pressing d shift and then dollar sign Just the nice nice little secret best kept secret of them many best kept secrets of them okay, so On operators and motions, so I sort of alluded to this before when you press d It is that is the action you're going to be doing And then the motion the key you type after d. Maybe it's dw for delete a word or delete D dollar sign delete all the way to the end of the the line You have different things that you can press. Okay So they mentioned So let's see an example of them. So we know dw. Let's try dw. So I'm going to delete the word start Okay, now that's gone. We can also say de And de deletes the word it deletes to the end of the word and notice leftover. We actually have two spaces That's the difference between d and e or w and e as motions Um now I should be clear in the same way that you can let's say Not deleting we're not talking about deleting at all Again, as I said, you can just press dollar sign to go to the end of the line or you know zero to go to the beginning or You know carrot to go to the beginning of whatever text you have um Additionally w and e are actually movement commands as well. You can actually just instead of okay If we're just pressing l you got to press it a million times to move out here You could just press w w actually moves word by word. It's a little faster than l Now, of course ours are super fast because you know, we increased our x rate so we can move quite a bit faster But you know either way w can move words and e means move to the next end of you know, the next word or whatever um And I should say the opposite of d if you so that's move forward a word if you want to move back a word That's actually just b. So if we press b you're moving backwards So hypothetically if i'm here on the word current I press d and if I press b, what is that going to do? Well, it's going to delete from where we are. It's going to delete backwards So it deletes the you know in this case it deleted the v before current Okay, that's what it does So the logic of vim is vim has a lot of movement commands that you know move around for you And you can put something like d for delete in front of them And it will delete and like instead of moving you there It will actually delete everything that you know would be you'd be moving over In fact in the same way I mentioned, you know the the curly brackets move up and down like through lines Well, what happens if i'm here? I press d and then I press the curly bracket It actually just deleted that paragraph that's below it very nice. Okay. All right So uh using account for emotion. Oh, here's another good one another classic. All right. Um, so in this case we have um So typing a number before emotion repeats it that many times Move the cursor to the start of each line below marked. Uh, blah, blah, blah with the uh the arrow This is just a line with words. You can move around in it. So here. Well, actually, let's see Let's see type 2 w to move the cursor two words forward. Are we supposed to do it from the very beginning? Oh wait, yeah To w. Okay Uh type 3 e to move to the curve move the cursor to the end of the third word forward. So 3 e Okay, um type zero to move to the start of line. Okay, et cetera, et cetera So the idea behind it is I just said that w moves you around you can also put in front of w You can put some kind of number that tells you how many times you do it So let's say we're right here. We want to move five words forward very easy five w Okay, very nice. That's so we we have our motions. We're adding in numbers. So um, what happens if we say D 5 w D 5 w what that does instead of moving forward five words It starts deleting from where you are to five words in the future. Okay, that's what it does So the motion commands and the deletion commands again, they're they're the same concept same thing and again if we want to say D 4 Left bracket that's going to delete the four, you know bracket movements up upward. So it's sort of like deleting four paragraphs kind of um, all right so Blah blah blah using account to delete more Um, oh, yeah, that's just I just told you that okay. So let's do this So they want us to delete stuff here. So here we have some extra letters We have two extra words. We can say delete two words. They're gone We'll move here. We moved there with the w command. We just moved over to the next word Now we have four words. We want to delete. We say delete Four words you're literally like you're literally just speaking in English to them and it just does everything You don't have to like imagine being one of those guys who just like manually types everything out or like Highlights it or something like that. I I can't even I don't know. It's like a totally different word world Um, so here we have three more. So d three w. Okay, there now. We got it now. Everything's cleaned up So that's how you do it. Okie dokie operating on lines lesson 2.6 Type dd to delete the whole line very very nice one Okay, so rose is a red mud is fun violets are blue. I have a car Clox tell time sugar is sweet and so are you So let's clean this one up mud is fun. Doesn't really belong. Let's get rid of that roses are red violets are blue. I have a car Notice i'm just pressing dd and dd works wherever you are In the line. It doesn't have to be at the beginning. It just means delete the whole thing A clocks tell time. That doesn't really make sense Sugar is sweet and so are you roses are red violets are blue sugar is sweet and so are you excellent Okay, so now we've cleaned everything up And notice let's say we're here Now I could dd to delete this line. I could also say For dd and that just deleted all four of those lines. That's interesting Okay, so next is the undo command now I'm going to tell you before we'll talk about that in a second But I want to show you uh, well actually I've been using the undo command anyway, right? So if I delete, you know for dd all these lines if I press to undo something You just press u Undo stuff. That's it. That's all you have to know or to redo stuff. You press control r. All right They're going to talk about that in a second. But here's what I want. Here's an additional thing. So Um, we learned that dw is delete a word, right? Okay, but here's the thing um Sometime if you're in the middle of a word if you press dw Look at what it did. It didn't delete. You know We were in the middle of roses and I said delete word Okay, it did it didn't delete the word it deleted from where we were to the next word But it didn't delete. I I wanted to delete the word. That's like the normal way to do it, right? Now the fact of the matter is whenever you have a motion Well, there are additional little modifiers you can put onto your motions Here or your text objects. I don't know the official terms, but here's the idea behind it. So you type d I'll just do it and I'll show you how it works. You type d a w that deletes a word and a means around it's like the word and any white space around it, okay So d a w deletes that word in the space the trailing space or whatever you can also do d i w And that deletes just the word i is sort of for inside Um, it really deletes just the word and not the white space around it So this might seem like an arbitrary You know d a w d i w now the the good thing about that is you can actually You know you you can do it from anywhere in the world word But also you can do you could it has different text objects aside from word So let's say i'm right here on move and I decide I don't like this entire paragraph Well, you could use w to delete a word, but it ends up p is a A text object for the entire paragraph. I can do this d delete around p for paragraph and it's gone the whole paragraph is gone d a p it's gone d a p d a p five d a p You know it it's it just works, you know um, so that those are uh, well, okay the real reason these are useful is this okay, let's say I have stuff Okay, let's say I have stuff in of some parentheses. Okay. I don't know if they actually bring this They probably bring this up later in vim tutor. I don't know if they do but Either way, let's say we're in these parentheses and I want to delete all this stuff in the parentheses Okay, let's see. There are five words. I could go to the very beginning. I could say delete five words That's correct. You could do that But parentheses are also text objects in vim so anywhere in here. I can say d for delete i for inside and just Parenthesis and it deletes everything in the parentheses. Wow. It's like it's magic. It's like magic or so that's di Parenthesis, but if you or yeah di parenthesis if you press da for around parenthesis That deletes everything including the parentheses It's magic. It's like magic So that's how you do text objects in vim. I don't know maybe vim tutor talks about that later I forget. I don't really remember like all the stuff they do So press u to undo the last commands capital u to fix a whole line. So let's go here Fix the arrows on this line And replace them with undo. Okay. I think that's all of it So we can either undo them manually Or we can just press capital u and undo them all and did they say oh, yes and control R So u is undo control r is redo, you know the thing that you undid There are also here's some crazy things about vim that i okay. I always forget this You can type in so, you know, we remember colons are where you type in vim commands like for example Which ones have we learned? We learned a sort. That's a pretty sweet one I guess there's a okay. Yeah, this line moved up here, but all the other ones are sorted by number Um, so another vim command is uh, what is it earlier? I want to say is it earlier? I think okay. Let's say earlier 5m Okay, what happened here? Okay. We're back here at the roses are red thing Earlier what earlier does is it jumps back? Five minutes in your history. That's what it does. It's like oh, wow I mean, so if you messed something up 10 minutes ago, you can literally just type earlier 10 minutes Earlier 10 minutes and it will go back 10 minutes. So now we're here back where we were 10 minutes ago Uh, or I suppose okay. What's the opposite of earlier? Is it later? I don't quite know. So let's go forward. Yes It's later. Okay. Now. We're back where we were. We literally just time traveled in vim You you wouldn't even think this is this is this old text editor. You it can time travel Okay, all right. Let's let's see or whatever you're using do that. I'm sure a lot of uh IDEs can do that nowadays. I I assume you never know but Uh, okay. So lesson two summary dw d dollar sign blah blah blah you will know all these the important thing is Um, there are special commands for you know motions for moving around like w is move You know word at a time b is word, you know move backwards by a word You know e is sort of like w but it moves to the ends of lines. Um You know, I talked we talked about brackets and the important thing is if you want to delete stuff You can just put d right before that and it will delete, you know, whatever, you know Let's say we want to go here. We want to delete. Um, you know delete three words delete three words. Bam Okay, additionally. I told you you can also use a or i for uh around or inside a text object So delete around a paragraph will delete an entire paragraph in the white space around it or dip will delete the entire paragraph It'll leave the trailing white space. See we're still on a blank line here, which would not happen if we did dap Now that that might see the difference between dap and dip might seem a little obscure But when you get good at it, you'll be like, oh, okay, I'll use this here and it just it's just like magic But definitely you should keep in mind using parentheses and stuff like that You know di parentheses that'll delete all the stuff in parentheses And also it works with quotes and stuff like that In fact with quotes it works Even better because you don't act or I think it does you don't even have to be in the quotes I can say di Quote and it actually moved to the next quote and deleted everything in it very interesting Um, although it can be a little wonky if you have a a line that has a whole bunch of quotes in it So you should always try and be where you know, actually where the quotes you want to delete are but All right, and we also learned how to undo and redo stuff Okay Lesson three the put command. Let's see how long we can do this I'm getting a little time I'm getting a little sweaty the thing is for my videos I always turn off my ac because it makes noise, but I don't know I'm getting a little sweaty now You know, it's just so we're going so intense vim diesel guys vim diesel speedrun Actually, this is not a very good speedrun. It's a let's play but whatever Okay, the put command Uh, so p means put if you just type it alone Obviously it's a text object if you press d or some d a before it p is a text object But if you just type p by itself it means put or you could think of it as paste because that's really what it does Here's the idea behind it. Um, they give us some lines here Um, so this is supposed to be a rose is a red poem And it has a is at the bottom b is the second one here c is right here and d is at the top We got to reorder this stuff. So here's how it works I can go here delete a line d d Remember that one and I can go up here to where I want it to be and I can press p To put it in or paste it in if you want to think of pasting Or I can go here dd delete that one move it down here press p to paste perfect It just works. So that's that's how you that's basically how you copy and paste in vim. Um, now I should say Um copying and pasting and vim because I know this is going to confuse some people right off the bat This is vim internal copying and pasting it doesn't have to do with your system clipboard. Um, that is if I if I You know delete that or whatever and then move to try and paste it in the firefox That's not going to work vim has its own Internal registers for copying and pasting things and this is actually a lot better for different reasons You can actually vim actually has as many plates like every key Okay, basically you can store things in particular keys And then print them out from you know the the buffer register or whatever they call it's very useful Um, but right out out of the bat vim does not have the ability to copy and paste using your system clipboard Um now or at least vanilla vim if you use g vim or I actually use uh neovim Neovim is basically literally exactly the same as vim Except for it has you know it has you can set it up to have uh, maybe I should actually just talk about how to do that Because people are going to get confused. I'm a neovim and uh in order to allow it to uh use the system clipboard You just got to put this line in I'm pretty sure there might be another. Yeah, I think that's it You just set clipboard uh plus equals unnamed plus uh release at least in linux You should probably look it up. Don't take my word on it right here. Just look it up online Um, if you want vim to use the system clipboard, uh, I think I You know I originally was skeptical of the idea because it's sort of a vim elitist thing to be like Oh, we don't need the system clipboard. We'll do our own thing, but it actually does sort of work out for different things Um, so just know it's it it's an easy thing to change Um, just either install g vim or uh, what is it vim? There's some other vim plugin that adds it in but uh, anyway I did a video on that a long time ago, but I just use neovim because you can just add in the feature itself All right, so the replace command Um type rx to replace a character with x. So replace by itself is actually not super useful Um, well, we'll we'll just do it. So here we're on this If we want to replace this a with the e we just type re something like that Uh, or here we'll replace that we'll replace Oops replace that with the wrong thing Okay, etc. Etc. Uh, another thing you can do Oh, you haven't learned visual mode yet, but you can actually replace Like, you know long sequences of things if you highlight them and replace but uh, or by itself I don't really find that useful. I don't really use it that much. Well, I don't want to say that Let me think let me think of the use of for it I definitely use that I will say that like every every once in a while it will come up, but that's not usually the way Uh, usually you use the you know c for actually they're going to tell you what that is. All right This is how you actually replace things. Okay, you use c. Okay, so Everything you just learned about d like dd to delete a line d dollar sign to delete all the way to the end of a line d3 w to delete three words all of those apply But with c and what does c do c delete stuff and then puts you an insert and load automatically What do I mean by that? So here's an example Um I would you know, I guess I could use vim tutor, but you know, I'm just going to do my own thing Here's an example here. I got um, so we already know that if I'm in these parentheses. I can press di Parenthesis and that deletes everything in the parentheses after that based on the stuff you already know You know that you could go into insert mode and keep typing right now c Is like it's sort of like both of those motions in one it Deletes stuff and then puts you an insert mode automatically. So if I I if I'm anywhere in these parentheses. I press c i Parenthesis I could just start typing. Okay, or let's do the things that they want us to do. Okay. Let's go down here Um, so this line they totally misspelled this So if we want to just replace this one word we press c w line Um, we can go over here to words. Okay, again c w Need is drastically misspelled. I don't even know how you misspell that. Well, I guess they yeah, I guess they shifted over One one key or whatever. So need c w Type it in press escape when you're done And then we'll go here using the change operator Okay, so all the stuff you learned about them or a lot learned about d in vim is true of c It's up for c just puts you in insert mode at the at the end of it And of course even you know, so I mentioned capital d is delete to the end of the line Capital c same thing except for now you're in insert mode. That's it And you might say oh well There's an entire different button just to like add a single key press just to like optimize pressing one key And yes, that's how vim works like you want everything you'll be changing stuff a whole lot when you're editing files So it's really great to be able to um You know just save you one key press because you'll be using this a whole lot All right more changes using c uh blah blah blah. They just said the same stuff that I was going to um Let's see the end of this line. It's Okay, I guess they want us to Start here so we can do c dollar sign to change into the end of the line But I'm just going to use capital c same thing as capital d But you know To be corrected using the c dollar sign command Well, they have an extra space there or something whatever man Who cares? Um, I don't know why I saved All right, so summary Okay, p to paste So let's say I well, that's another example Um, let's say I delete around paragraph. I've now deleted that entire paragraph. I can move somewhere else That's deleted of course, but if I press p bam it reappears it reappears where my cursor is So I can move anything I want around. I want to move this around I'm going to mess up all vim tutor. Okay. That's that's what I'm doing I don't think I've ever seen vim tutor so brutalized. I haven't used this thing a long time You know, I've actually guided a couple people in real life through vim tutor like sort of uh, I mean it's sort of like It literally is like teaching someone a new video game or something, you know um, all right So cursor location and file status. Maybe I should break this up into multiple videos, but I I I keep doing it So I don't know. I'm not too tired yet. Maybe maybe I'll Maybe I'll break it up. I don't know. All right cursor location and file status So type control g to show your location in the file and file status So you'll see down here. It says line 487 of nine hundred and sixty two and also 50 percent Okay, we're 50 percent through the file. That's what that means. So here's what you can do in vim If let's say I want to go to 20 I want to go to one fourth through the file That is like to the one fourth of the way through the file. That is 25 percent. Guess what you do. Here's what you do two five percent Now you're there now we can actually press control g and confirm Oh, we are 25 through or let's say well, uh, 75 percent. Okay, or let's say a hundred percent um, now of course you would never actually type 100 percent because Yes, because there is capital g if you press capital g at any point in time It goes to the bottom of the file you're in or if you type lowercase g twice g g it goes to the very top Okay, so that's that's how you get around Yeah, I'll use capital g and lowercase g g over and over again And of course if you don't want to use those you can always use percentage signs to get fine grain control over where you're going to Go 90 percent, uh, you know 33 percent whatever. Okay um, so that's that And as they said control g shows you where you are All right the search command Yeah, I guess it's been sort of a long time to get all the way to the search command But it is an important thing basically slash as search So if you press slash notice that in the bottom of your screen you have a little thing where you can type And let's search for lull Doesn't appear a pattern on found. Okay, uh search for vim Okay, vim exists. So it found this instance of vim here If you want to go to the next instance you press in In in in in in or capital n goes backwards previous instance Uh, let's go back to approximately where we were um Okie dokie search command All right, that's pretty much it for that All right. I'm I'm bored with the stuff they're talking about now Here's some other things that are a little bit useful about them because uh, oh, actually they're gonna talk about parentheses. That's good But uh, here's another little thing. What for example does o do we're learning we're learning more about these buttons at all What does o do o is a very useful command? Let's say it really is Uh start a new paragraph like let's say we're at the end of a line o means start a new paragraph and put me in insert mode Okay, that might sound like a totally arbitrary like what again, that's one of those weird key combinations Because you could at any point say Uh, let's see how would you do it go to the next line and then enter insert mode And then you know make an extra line and then go into you know, you could do that But o just sort of saves you uh a couple key presses. You'll be using o a lot Now capital o does the same thing but reverse If you if you're at the top of the paragraph and you want to start before that add in another paragraph or something like that That's what capital o does. Uh, so that's another little uh little tiny tip All right, so matching parentheses search Blah blah blah. Oh, okay. This this is a sort of interesting one. I don't really use this that often But it's an interesting one. Basically. Here's how it works. You can go to any Let's say you have a parenthesis You know, hopefully it has a uh a buddy on the other side a matching parenthesis And if you're if you have one of those parentheses highlighted if your cursor's on them You can actually just press percent and it will jump to the other one of of those Or if i'm on this parenthesis, I press percent notice I go back to that original parenthesis and it works for brackets and it works for uh, I wonder if it works for quotes. I've never thought about that see quotes are harder to do because you don't like I don't know No, it doesn't work with quotes. Dang. Oh well But uh, so this is something I don't use this as much. I like I feel like it is theoretically useful I can't think of a time when I've used it especially because if you're doing stuff like let's use what we learned before Change in parentheses You know that takes place of a lot of the times you might need to do that, but I think they say there I think they say here Uh, yeah, this is very useful in debugging a program with unmatched parentheses Because you know if you have a really big, you know, let's say you have lines and lines like a block of code And some parentheses is somewhere and you're looking for it You can always use this to check if there's a match Okay, okay, so now we're going to get into more substitute commands Now I remember when I first took vimtude or I first used it I remember learning substitute And it just went out the other ear because I was like what I that's confusing man Like I don't want to have to remember that but that was before I knew Regular expression. This is basically like said like a said replace command. That's basically what it is So as I said, we know some, you know, we know some vim commands We know quit we know sort Stuff like that We're gonna the s command, which I guess is sort for short for substitute Basically replaces one. Well, let's just do what they tell us to do. All right. Let's be good boys um, okay Or do they okay now we'll start here So to use the replace command you press call you go You know press colon to run a command. We're running the s command Uh, then you put a slash and you say what I want to replace and in this line Uh, the word v is spelled with two e's so I want to replace that, you know, v with two e's What do I want to replace it with I press slash And say the um, and then you press slash again Now if you just ran it like this, it will only modify one of the instances The important thing you got to do is press g at the very end and that replaces all the instances Now this might seem a little obscure But if you you know watch the channel if you use said if you use a lot of command line options and stuff like that This is exactly the same syntax as said It's just really the substitute command the thing you replace with the thing you replace it with And then some options g is, you know, the most common one If you don't run g it will only replace one match on the line you're looking at if you are Or if you do run g it will replace all of them Now additionally they note, uh, you also have some other options here So if you put parenthesis at the beginning of your substitute command It will change every occurrence in the whole file and, um Yeah, so it's it's pretty convenient to add that stuff in I think I actually in my vm rc Because this is sort of I will admit this is sort of a pain to type out because often you you know You're in a file and you want to replace Uh, you want to rename a variable or something like that? So you want to use one of these commands, but it's sort of a pain to type out in my vm Or my you know neovam or whatever. I actually just have it bound. Let me show you so the the The the okay, I actually just have it bound to like capital s if I just type capital s It actually writes the syntax for me and I can say replace the with lol Okay, so it replaces all of those instances But you you'll have to look in that how to do that in your vm rc to figure that out Well, here I should just show you. I don't know. It's a vm tutorial Um map s Yeah, it's basically this so This means remap and this is your so your vm rc It's where you edit you add in vm commands or vm setting stuff like that I just remap capital s To be this sequence of key presses So I type out the syntax for it and I press left left to go back so I can start typing in the in the little brackets all right So lesson for summary. All right. How how much how many lessons are there? Maybe I should check out I don't know. I I noticed that I'm getting a little sweaty here again. No ac. It's such a pain So control g you learned about that importantly gg to go to the top Capital g to go to the bottom. Also. Oh if you press a parenthesis or if you press quotes or whatever Let's say I'm here. I go to uh, you know 25 percent I can actually press quote quote to go back where I was a second ago That's just always what that does or uh, well, anyway Where were we so let's see what we were talking about we were talking about this stuff, right? okay, all right, so um Slashes search. I didn't mention it. I mean they did but question mark is search as well except for by default It searches backwards and remember when you know if you're using the default search that's just slash You will be you know, it'll find the next match press in to go to the next next match And capital in to go back question mark is just that reversed You're looking upwards in will go further up capital in will go further down I always get confused by question mark or not confused, but I just find it a little unnecessary since you can Well, I mean, I guess if you're looking for only one thing that's only up Anyway, and then you have these substitute commands Okie dokie, so How to execute an external command now this might be useful for those of you who um, You know already know shell scripting. I will go ahead and say when I learned them I didn't know nothing about the linux or you know typing things on the command line It was actually where this is weird to say, but I actually learned them on windows That I know that's a weird thing. I I know a lot of people them runs on windows I know that in fact, but I mean it does and that's where I originally learned it So anyway, so colon plus exclamation point. That's actually the universal sign of run a shell command or something like that So I can do this I can type l at do I want yeah, I can type ls It'll show you all of the stuff that's you know, it'll it's like running ls in your actual terminal It'll show you the contents stuff like that Um, so that's that blah blah blah You don't think they tell you anything else More on writing to files Blah blah blah blah. I'm a little bored Uh, oh, all right. Here's some good stuff. All right, selecting text Uh, this is important now. I've done this actually a couple times in this video Basically, so we've learned about two different modes. There is um, you know insert mode You can go there by pressing i or a or c Plus a combination of motions And you can insert stuff and of course normal mode Again, normal mode is when you have all of your key your precious keys are all shortcuts to make you I don't know cat and kirk and his little command line or command line console Um v is visual visual selection So v if I press v I can just move around and that will select stuff I can use any of the motions that i'm familiar with You know brackets or something like that or control d or something like that And it will move around and it will visually select everything In fact, you can use it with something like, you know, we talked about d a p to delete all of a whole paragraph d a p Undo that you can also type in v a p and that will actually, you know, visually select the entire paragraph That can be useful. I mean you can continue to change the visual selection or something like that Have they taught you about yanking and copying and stuff? I don't maybe they haven't anyway. Well, I guess I'll tell you about that now. So You can well, maybe you don't actually need to visually select to yank stuff, but uh, sometimes it's helpful So d a p to delete all the paragraph y a p Yanks the whole paragraph meaning it basically copied it Okay, so I can go somewhere else and I can paste it in right sort of weird pasting it in itself But you can go and paste anything in with p. Okay Um, but you can also if you have visual selection, you know, let's say you have something visually selected You could also just press y to select that In addition to lowercase v. There's also capital v capital v Um, so lowercase v to be clear. Let's say I'm in the middle of this line Lowercase v, you know, you just sort of manually move to the stuff in the line you want to select Capital v selects everything by you know line by line. Okay, so if you have Any part of a line you have all of it. Okay, so it's going to select everything like that and there's also control v Control v actually moves like this. So it doesn't move with the stream of text So to be clear actually if I use normal v You know, I don't have a block selection like you might want but um, you know Control v that's what control v does you sort of get a block selection and you know, let's say I decide I don't like this text d to d to delete. It's all gone. All right Okay, okay, uh retrieving and merging files They're just gonna have you do boring stuff the vim tutor sort of gets boring as it goes on Um, yeah retrieves this phone blah blah blah Open command Um, oh, yeah, I guess they do tell you about oh, you know open up a new line Okay, okay Let me see if there's anything else I feel oh append. This is wait No, no, no, no. No, that's not what I thought. I thought it was period. All right. Here's another cool command period Most important command. I don't think this is actually in vim tutor. Here's what it is. Let's say I Okay, here's an example real life example Um, let's say I have some stuff in this some parentheses. Okay, then I have some more stuff. There's some more parentheses Okay, then there's some more stuff and then you know more parentheses and there's more stuff in that Notice everything in the parentheses, right? They're all different. There are different numbers of words and stuff like that so Let's say I want to go and replace everything inside of these parentheses with You know, I don't somebody's name or some variable name. Okay So we already know if you remember See is change and if you want to change the things inside of a parentheses parentheses pair parentheses you say Change and then I for in and then parentheses. So see I Parenthesis now you can type whatever. Let's say we'll call this billy. Okay now the thing in the parentheses. It's billy So here's the cool thing. Now. Let's go to this other parentheses Okay, hypothetically, you're you're there and you want to do the same thing now. What would you do? You you would type see I and then parentheses and you would retype billy, right? No, you wouldn't do that Here's what you do. You press period. That's all you got to do You just type period and vim what period does is it read does The last command you did so I can go over here. Press period again. Bam billy. Here's another example Okay, here is some text. Okay. I'm actually gonna So maybe I should explain. I don't did they not talk about yanking? Maybe I just skipped over that but You know, so dd delete a whole line to yank a whole line yy Okay, so now we have yanked this so I'm gonna paste it a couple times, you know, maybe I'll say five and paste that Or maybe well, anyway, I don't want to complicate it. So another thing you could do um Is let's say we're on this first line And we want to add some text to the end of all of these lines There are more they're actually multiple ways to do I mean there are a million ways to do everything in vim all of them more efficient than the others But here's an example. Let's say the first one, you know, I go here and it was like um I need to add Some more to each line Okay, so I pressed capital a to go to the end of the line and insert and then I type the stuff I wanted press the escape now. I'm back in normal mode Now you might think if I want to add that to every other line here I would have to do that manually and blah blah blah. No, you just type Doll or period period period or actually, you know, let's let's do it even more efficient than this another Vim command that's very useful is the normal command So let's say I have all of this stuff highlighted I'm going to press colon to go into command mode and I'm going to say norm Norm is a fantastic command What it does is it says I'm going to run the sequence you gave me in normal mode on all of these lines So I'm just going to press period and it just did all of that for me. Wow. That's magical It's the this this kind of stuff is it's fantastic when you're doing it in real life You'll be like especially norm. I love it as a command. You can do all these these crazy things. You just got to keep it in mind, right? um But you know if you forget norm again, you can do them manually or uh, do they teach macros here? Maybe I should talk about macros. I don't know. Um, but uh, anyway, let's let's not complicate it more Well, I'll just just for evenness sake norm Bam. All right Another way to replace. Okay. This is a good good thing to do So type capital r to replace more than one character. So I said that the regular r, you know, if you're Manually replacing something with r. It's very inefficient because you got to do it one character at a time It's like deleting stuff with x. No one actually does it But capital r puts you in replace mode Where basically you just overwrite the text that's already there. Okay, so here's the example they give us They have xx x and they want us to replace it place it with four five six Now as you already know, you could do c w right c w or you know, even if you're in the middle of it c i w Right and then you could type You know that stuff and blah blah blah But you could also use r um and r you just press or capital r to be clear and I just type four Five notice they're overwriting the x's six. That's it. Okay, press escape when we're done. That's replace mode Or I can go here replace mode five Seven nine now replace mode is actually for totally different use cases than change because here's why Let's say i'm here. I want to replace gives with um, uh, I don't know Bestows or something like that. Let's say I type capital r Bestows Oh, look at that. It actually overrided the text that follows after it So capital r is only used for replacing something of the like the exact same number of stuff Um, now this is still useful. It's still replica. You know, you can still press dot to to redo it or I'm pretty sure you can Yeah, um, but I think in 99 percent of the time or at least 95 percent of the time you want c w or c a w c i w Um, so bestos Okay, um, you know vim does actually I thought for a second. Is that spelled right besto? That's not a word you use that often vim does in fact have a spell checker. Actually, maybe I should Bring that up. Um spell Okay, uh, I always have to I have it bound to a particular key binding in my vim But you can do this you can say set local Shoot I might actually have to download a dictionary for that spell link equals in us Okay. Yeah, okay. So notice what happens is escape here Uh became highlighted. That's because I have my spell checker on so spell Uh, blah blah blah. Well, that's not spelled or spell is not spelled wrong, but it will also um highlight stuff That's like, um, you know not capitalized or stuff like this So this is you can see that this word is not a word You can go to it and you can uh, you know, you oops You can press well, maybe I'll get a word that's closer to being a real word. Let's say apple Okay, it's suffer with only one p you can press z and then equal sign And it will actually give you a list of words that this thing could be. Wow. Look at vim I'm look at this minimalist text editor that or at least it looks minimalist It actually has literally every feature in the world blow But you you can type which word you actually want it to be and bam So let's say I actually did forget how to spell bestows Okay, it would oh look that's highlighted. So I'll say z equal And oh, there there's the correct spelling or maybe we'll we'll say beast those Why not? Okay, so that's how you do it. And also if you have multiple misspelled words Okay, you can go from misspelled word to misspelled word using um, uh bracket s Okay, so we're jumping forward to different words Now look at look at my words. They're so the colors are so bad. I need to change that. I think that's in my own configuration Okay, so oh, yes now we're talking about copying come on I've been waiting for this this this vim. Let's play has been I don't know twists and turns for me I always forget what's where so use y to copy text and p to paste it So, you know all the stuff you can delete or change with c or d you can use y on So again y y is Copy a whole line. You can paste it in how many times you want. Let's say i'm here I want to copy just two words so I can say yank two words And then I can go here visual mode visual mode visual mode visual mode over and over and over again That's how you you do it or even here, of course Yank inside parentheses that will copy out paste And i'm pasting it inside of inside of itself or I can say yank around parentheses and kids. What is that going to do? That's right. It's going to copy the parentheses too All right, so we're going to paste those in as well. I don't know why I talked to o there. Oh, I guess I was pressed o twice all right, um set option Just this just learned learns you about um, and how do you look at? uh set local spell Hey Oops, I'm gonna turn off that uh spell check Okay, all right. So the set option is uh, just sets variable Sets variables. So one example that you might want to use is ic So here's an example. Uh, let's say right here We have the I don't know why I'm pointing to it like you can see what you know what I'm pointing at But let's say we have the word search here Okay, and we want to look for that word search. Well, I'm going to press, you know, uh slash and I'm going to type in search Okay Oh, it didn't work It found this search and it found this search But it didn't find this one because it is not case and sensitive by default But you can set the command set ic Okay, and now if we we search for it. Ah, it shows up because searching is now Uh case and sensitive you can also set as they say hl search Say set hl search And that will highlight whatever you're searching for. Um, so The so all of these things now you might say, oh, that's all this stuff is hard to remember all these variables I don't want to have to remember that you don't have to remember that because what happens is when you You know as I mentioned if you want for example the ability to copy and paste from your clipboard Well, you got to use neo vim or something like that But you can just put this line in your vim config file The same thing if you like for example highlighted searches You can just put set, you know, I could just put in Set hl search in my vim rc and whenever I open vim that command will already it will automatically have run Um, so it's very very nice. Uh, I actually really hate highlighted search. So I'm going to turn this off. So What is it? No hl search Man, I really hate highlighted searches. It's so annoying. Um Okay, so we talked about oh, I had talked about it earlier. We talked about a All the stuff we've talked about blah blah blah and variables getting help Um, you put comments in the video description. I don't know. Anyway, vim has actually a help menu If you type in help and then you say you want to learn about vim panes or something like that Oh, look it pulled up information about panes or something. Or is this actually better? Yeah, whatever. No, this is just to help um So anyway I don't you have to actually search. Let's see Who knows I don't actually use help Uh, okay creating a startup script. That is actually vim. That's vim rc. That's what I was talking about just a second ago Um, so just to be clear You know, well, maybe I should say what an rc file is Is it like at the end of this video and should I not talk about that? But anyway, the idea in case you don't know In case you're totally new here and you just you just watched like I don't know how long I've been recording this But all this vim stuff just in case you don't know Files like vim usually have something, you know called an rc file Okay, usually you keep your vm rc in your home directory It's dot vm rc and you can open it up and you can put all your favorite settings Set hl search, you know stuff like that You can put all the settings you want that I just talked about a second ago in there Okay, now mine is not in vm rc because as I mentioned a second ago. I use neo vm. It's in a slightly It is in where is it? It's in uh config slash neo vm slash in vm slash init dot vm, but anyway, that's not important Uh, okay command line completion with yeah, you know how to tab complete right guys So you can do stuff like no hl and then type tab Basic command line thing works in vm works everywhere else. I think I think we're about done I think that's about it. That's our let's play a vim tutor. So this I'm glad I'm vim diesel I've been your uh guide through vim tutor. Hopefully you made it through Uh, you probably missed a lot So do it over and over again that there's no shame in that I did vim Vim tutor multiple times when I started I've helped other people through vim tutor multiple times I went through this very fast Sorry if I went a little fast if this is like your first time. So just do it on your own pace Really watch the video if you want have fun. I I've said this in other videos There are a lot of things I do on a channel that are you know, maybe a little niche And I've found a lot of enjoyment from and you can optimize a lot of stuff with But a lot of them aren't for everyone. I will say vim is one of those things that should be for everyone like everyone who knows um You know who is doing anything on a computer should learn how to use vim what we've talked about now Hopefully we've learned some cool stuff, right? But what we've talked about now is just the tip of the iceberg vim is so powerful Despite being this little tiny program that's installed on every single server You know if you really get to learn to use vim You will never be like, oh, I wish I had this ide on my, you know server or something like that It is so Powerful you can get so much out of it and it happens pretty quick. So You do you you do your thing Um, this has probably been the longest video I've done in a long time I just had nothing to do this this afternoon Um, so I'll see you guys next time. Enjoy it. Enjoy vim. Have fun Redo it learn something Yep