 Alright, what's up everyone? I had the realization that there are a lot of people who use Vim and use it well But they've never learned how to do macros or they've never learned that functionality and they're really great people should use them So in this video, I'm just gonna show you how to use them basically And they're very you know, you can do crazy stuff with them But anyway in a previous video. I told you how to map in your VM RC different key presses to different mappings and Recording macros is sort of similar in that you're recording key presses, but you can actually do it real time in Vim So it's pretty nice. So here's what I'm gonna do in this video. I have this Here's my wallpaper folder or specifically my landscape folder And what I want to do is I want to take all these files and feed them into FFM peg to make a slideshow Automatically, but that's not the important part the important part for us here is we have to take all the file names and put them in a Particular Syntax in a file to feed it to FFM peg. So what that's gonna look like well first off I'm gonna take if I take LS I'm gonna feed it to Let's say a file name, you know file list, okay? I'm gonna open that file list up. So this is a file in Vim It has all of the files in this folder and here's what I want to do to make to be able to feed it to FFM Peg I have to turn it into a particular syntax and it's gonna look something like this You have to have file Open a quote and then quotation marks basically go around the file name then below it you have Duration and then some duration let's say five and that just means five seconds. Let me this is all distracting for now So basically we are gonna want to put every single file name here in the kind of this kind of syntax where we have You know in file then quotations and duration So if you are just I mean, you know, if you're using notepad or something I mean, obviously that's a very difficult thing to do. We have a hundred seventy nine Files here. How are we gonna go through the mall? How are we gonna work this out? Well, basically what we're going to do is we are going to record a macro to do it now How do we do that? Macros are super easy first. I'm gonna put my cursor wherever I want to start And I'm gonna have it right in the first line first character here now to record a macro What you're gonna do is press Q Then you press another key and that key is gonna be where your macro is saved I'm gonna press W for wallpaper just because you know, why not? So now you'll notice it's saying recording at W that means you're recording your macro. That's good Now here's the idea behind macros Every single key press you press from now on until you press Q again in normal mode is gonna be recorded in this macro So what I'm gonna want to do is I'm gonna run a record a macro that Puts this puts one line in the correct syntax. Then I'm gonna repeat it a gajillion times for all the other ones Okay, so here's what I'm gonna do I'm gonna first I'm gonna press capital I Capital I goes to the beginning of the line and puts me in insert mode I'm already at the beginning of the line, but I just want to be careful. I'm gonna type file Space and open our quotes now. I press escape to get in normal mode now instead of keying over with L Or something like that. I'm gonna press capital a so that moves me to the end now The reason I do that instead of keying over is that if we have a file name here with a different length Then the appropriate number of key presses will be different But if we press capital a will always be at the end so press capital a now quote now I'm gonna press enter And I'm gonna type duration and I'll say five And so that's all the stuff we have to write But I also want to have the cursor end up where we started that is at the beginning of the next file name So I'm gonna press escape or to get back in normal mode J to go down and then Zero to get back to the beginning of the line now our macro is totally done Of course, it still says recording at W to finish the macro totally just press Q Now all of those key presses are saved to at W now in order to call that macro All you have to do is press at capital to and W So at W gives you this it just repeated exactly the key presses you had before So at W at W very nice now if you record multiple macros a Shortcut it to get to your last macro pressed is just at at so if you just press at at it Just repeats whatever you did last Now these macros can be called Iteratively so let's say I want to do that 50 times. I just press 50 and then at W now it's repeated 50 times I've gone through 50 more of the file names or we can do it a hundred more times at W bam here we are now you might wonder If we go all the way to the bottom, so we have a couple more file names You might wonder let's say I press this like let's say I press a hundred and then at at Is it gonna get to the very end and then continue to press it until it gets to a hundred? and the answer is no Vim is actually pretty smart in terms of When it's going to you know stop running recursive macros So even if I you know, I only have what like 20 of these left if I press 2000 and then at at it's actually just gonna stop once it gets to the very bottom So it's not gonna come continue doing the macro over and over again So it's actually pretty smart about that So anyway, that's that's basically it. That's how you record macros And the other thing about them is that if you leave them and come back into your file You can actually press it the macro will still be recorded. So you can have a couple of these just saved You know that you need on the fly, but anyway, basically what we've done in this video is we've taken you know a List of files and we've converted it into the syntax We want really only writing it once and then repeating the macro So that's the beauty of them and these are the kind of things you can implement really quickly and they're very useful So anyway, hope you learned something. See you next time