 Okay, so we're back again with some more VimTutor stuff, right? I guess we did all of lesson one last time, so now we're going to start with lesson two. And, of course, we're not just doing the lessons, we're doing all the stuff that I think is important. So, same time, same place. I think I changed my background. Actually, I moved the web camera, so that's definitely different. Okay, so anyway, let's go ahead and get this thing started. So, deleting commands. Well, actually, we should probably do a brief review. I'm going to turn back on my screen key. So, Hjkl is move, of course. You know how to quit with colon Q. I'm not actually going to quit now. We talked about moving up and down with control U and control D, and moving to different portions of the screen with H for high, M for middle, and L for low, all of which are capital. And, of course, different ways of going into insert mode, so capital A to go to the end of the line, capital I to go to the beginning, lowercase A to go to the right of a character, lowercase I to go to the beginning. Nice and nice and simple. So, lesson two. So, lesson two is going to get into some more interesting commands, but also command, even more interesting is the stuff that they don't actually include in VimTutor. So, anyway, let's go ahead and sort of follow what they're doing. So, move the cursor to the line below marked with an arrow. Easy enough. Move the cursor to the beginning of a word that needs to be deleted. Retreat, yeah. So, just repeat until all the words are deleted. So, our sentence here is there are some words fun that don't belong paper in the sentence. So, we can go over to the words that don't belong and say DW for delete word. Delete word, delete word. Nice and simple. There are some words that don't belong in the sentence. Okay, nice and easy. So, now Vim doesn't tell you this, but you've actually done something a lot more magical. Now DW is not just the shortcut for deleting a word. It's actually two different shortcuts. D means delete and W actually just means word. Now, we'll talk a little bit more about this later, but I'll go ahead and tell you actually, yeah, we'll talk about more about this in a minute or so. Let's just go ahead and do what they're telling us to do first. So, more deletion commands. So, D and then dollar sign deletes from a particular point you're at until the end of a line. So, I can go here to this. We have someone typed the end of this line twice, end of this line twice. And if we go here and say D and then dollar sign, that deletes from that point all the way to the end of a line. Nice and simple. Now, I'm going to undo that for a second. I will say D dollar sign is a little hard to press, especially if you don't have a dollar sign on your keyboard. But even if you do, it's a little hard to press shift and then move your finger all the way up to a four. That's sort of a pain. So, I'll tell you a secret. You don't have to actually press D dollar sign. You can just press capital D. It actually does the same thing. I don't really know why they tell you to use capital or D dollar sign. But I will say that dollar sign is actually a general movement character. So, if you're in normal mode at any time and you want to go to the end of the line, you can just press dollar sign. Now, keep in mind that's different from capital A. Capital A means go to the end of a line and go into insert mode. While dollar sign just means go to the end of the line and stay in normal mode. Anyway, going on, so operations and motions. Now, this is where the magic of them really starts. Now, as I said, DW isn't just some hard coded command that means delete a word. It actually is literally there is a delete command and it is run on a kind of object. And you give it the object of a word. So, here are some other objects you can give it. So, when you actually type in DW, you're saying, well, actually we'll put it this way. If I go to this line and if I just type W, you'll see what happens is we are now moving right one word at a time. And actually, this is a much more efficient way to move around than using J or K or excuse me, H or L to move left and right in the line. You can actually just type W to go forward a word. And they don't say it here, but you can actually type B to go backwards a word. So, those are nice and easy to remember. W to go forward and B to go backwards. Now, the thing about it is any of these can be combined with the motion D or excuse me, the command D to delete all that stuff until the point you would move. So, what I mean is if I go here and I type D and then W, that's going to delete the whole, all that space up until the place that I would be if I press W. So, if I'm here and I press W, I go to F. Now, if I go back here, press DW, I delete everything till that F. That's really what Vim is doing. Now, in the same way, if I'm at this L and I press W, it goes to this F. It still goes to F, no matter what. Now, if I press DW, you'll see that it actually, it doesn't delete the actual word, delete. It just deletes from that point till the next motion point that you're going to be at. So, that's sort of an interesting aspect of Vim. What you're actually doing here, when you're pressing D plus something else, you're saying delete to the point that I would end up at if I ran this command. Now, in the same way, you can do stuff like DJ to go down a line and that's going to delete the line you're on and the line below. DJ or DK is going to delete the line you're on plus one line up, et cetera, et cetera. Now, one other thing, let me move around a little bit. So, this should give you an idea of how to move around. Now, what if, let's say, a position you're going to be in a whole lot is you're going to be in the middle of a word and you want to delete this word. Now, if you press DW, it doesn't really delete the word. That's not exactly what you want to do. Now, so if you're an introductory Vim user, what you'll be tempted to do is just manually move back and then press DW. And that's a little more efficient, but it's not the most efficient solution. The most efficient solution is between, you know, operations like D and motions, there's actually another thing that you can stick in between. And that is, what's the actual name for them? I don't know, but they're I and A. I'll show you how they work. So, if I press DAW, that's going to delete that word. And it's going to delete that word from any point in the word. So, if I am here on E and I press DAW, it's going to delete all of that word, unlike what DW would do. Now, you can think of A as meaning around. What that means is delete this object, a word, and any white space around it that is not going to be relevant anymore. So, it doesn't just delete this word, it also deletes this white space here if I press DAW. Now, contrary to this, instead of A, you can also use I. So, DIW means something like delete inside of a word. So, if I run that, DIW, you'll see that the two spaces that were on both sides of this word are actually still there. So, that's the difference between DAW and DIW. You might want to use one sometimes and one the other. Usually, when we're talking about words, you usually use A more. So, this is something that VimTutor doesn't mention. Now, in addition to talking about words as objects here, you can also treat paragraphs as objects. So, for example, this thing here is in effect a paragraph. What I can do is I can be anywhere in this paragraph and if I run DAP, that deletes the entire paragraph, or DIP does the same thing, but DAP is deleting the extra white space. So, DIP has these two white spaces here, DAP is going to get rid of one of them. So, that's the difference. So, you can run with D as a command. You can run it on motions. So, you can say delete up until the next word, or you can say something like delete this entire paragraph, delete this entire word, or trying to see, well, let me actually add some text on here. It can also delete sentences. So, let's say I want to delete this quote-unquote sentence. All you have to do to that is actually just DAS. That sentence has now been deleted. Anyway, that's the magic of VIM. I'm actually surprised that they don't talk about this kind of stuff in VIMTutor, but anyway, that's sort of the magic about it. So, this is motions, operations, stuff like that, and I guess text objects as well. Now, 2.4, you can also, in addition to running DW or something like that, you can also specify how many words you want to delete. So, I can go up until, well, let's go ahead and do what they tell us to do. Move the cursor to the start of the line with the arrow below, blah, blah, blah. So, this is just the line with words you can move around in. So, if I press W, I'm going to go forward a word. And again, B goes back a word. But if I want to go forward three words, I can press 3W. Or if I want to go forward five words, I press 5W. Or back six words, I press 6B or something like that. And this is very useful. Now, you don't just have to use these with W and B. You can also use them with HJKL. So, if I want to move five characters to the right, 5L, 5L, or 10L. Or if I want to move 10 characters up, 10K, or down 20 characters, 20J, et cetera, et cetera. So, using counts, so you have these commands, you can iterate them with counts. You can also perform them on different objects and stuff like this. So, you're sort of getting a feel for not just how each of the keys in Vim is a shortcut, but how the different keys can combine to create a more intuitive way of approaching actually processing words. But let's keep on going. So, using a count to delete more. Actually, I guess, oh yeah, I guess I didn't mention this already. So, we see here that there are some multiple words that we want to delete. And I can just say D2W to delete two words. Or I can go here. Looks like there are four we want to delete here, so D4W. Or go here, D3W. Now, I should say this isn't relevant in this document. Now, we talked about W and B for moving back and forth by word. Now, sometimes, let's say we have a word that looks like this, okay? Really ugly word, no white spaces. If we press W to go through this, you'll see that what it actually does is it goes to the period, W, W. Then it goes to this period and it's just sort of, it's not exactly how you expect it to be. Like, there's some sense in which you expect this to be a word. Where Vim treats it really as multiple words separated by periods. Now, W is not going to treat this as one word, but you can actually run capital W. And capital W is in effect a text object that treats this entire thing as one big word. So, if I press capital W and I press capital W, it's just going to go straight through all of this entire line. So, capital W is only looking at white space. While lowercase W is looking at things like periods or slashes or, I forget exactly what the characters are. And I think you can change them what it treats as what. And the same thing is true of capital B. So, if I press capital B, I can just easily move backwards over this big, ugly word. While if I just press lowercase B, I would go through, you know, the periods manually. Okay, so operating lines. There's a whole lot that I'm going through that's not actually in VimTutor now, but hopefully this makes sense. So again, just to refresh the stuff, you know, D-A-P delete around a paragraph or something like that. Or, you know, D-A-S for deleting a sentence, something like that. Or D-A-W, D-I-W, etc., etc. Now, you can also treat lines as separate objects. And Vim does this in a different way. It's not like there's, you know, a separate text object line. But if you want to delete just one line, all you do is just press D-D. So if I go here, so roses are red, mud is fun. We'll delete that line, D-D. I'll delete this line, D-D, D-D. And now we have what we want. And of course you can combine D-Ds. If I press 2-D-D, that's going to delete two lines, etc., which is actually the same thing that D-2-J would do. Or excuse me, D-1-J, I guess. Yeah, D-1-J, excuse me. Or just D-J, silly me. Because D-2-J is actually going to delete three lines because you delete the line that you're on, and then two more, anyway. So operating lines, let's go further down. So one thing that I've actually been using this entire time is Undo. So Undo is exactly how, I mean, it's exactly like, what is it, Control-Z or whatever it is in most applications. Where it just undoes whatever last operation you performed in insert mode or something like this. So if I press capital A and I add some text here, and then I can go somewhere else and press U and that undoes it. So I'm going to, let's say I add some stuff to different lines, I can press capital U to undo it. Control-R is going to redo that stuff if you undo something. So that's just your undo and redo commands. So that should be nice and simple. Okay, so that's actually all of lesson two. I encourage you to play around, do the specific instructions they tell you to do in all of these. So they talked about deleting words or motions. So W to move through a line and also B to move back a word. So we'll actually do them. So W versus B, you can combine those with D. So if I say DW, that means delete a word. You can also use numbers to do things multiple times. So 5W means move five words. Or you can combine that with D to say D5W to say delete five words. And I also added stuff about text objects like delete around a paragraph or delete around a word. And the advantage of that is you can operate on a text object while inside of it, while DW is just going to work when you're at the beginning of a word or something like that. And I guess that's about it. So this has been sort of text objects and stuff like that. Again, I'm getting a little thirsty from talking all this time. So while I have my water here, so I might as well drink it. But that's going to be enough for this video. I'm going to cut it short right now and I'll see you guys next time.