 So if you're a normal person and you hear people talking about Vim or Emacs or all these extensible text editors You probably think like it's a big joke or it's something just for like weird programmers But I wanted to do this video just because I wanted to show off just a little optimizations you can get from Vim You know just from playing around with it just like in the day by day stuff you have to do So today I was a little bored so I was going through my folder of TV shows. Of course, I download everything I watch It's just my habit So I'm not vouching for all the TV shows in here by the way. I'll just say that but anyway So if you'll notice, you know over here on the the right side There's some some names that are sort of you know all jumbled up And I like to have my file names nice and good-looking and stuff So in this video, I'm gonna show you what Vim can help me do You know just renaming files and mass and stuff like that So I'm actually in Ranger for those of you who don't know Ranger has this very nice function called bulk rename And what it does is it can open up all of these file names. Let me actually make these a little bigger It can open up all the file names in a Vim buffer and I can modify them here and then save it And then it'll rename all the files for me. So that's a nice thing So in this so here's my goal that I want to do in Vim So I have all of these names all these different lines I want to convert them into something more simple something more readable So I guess here I want to have let's say I want to say like episode and then the episode number And then I want to have the name of the you know that the actual episode I don't want to have any of this stuff. I don't want to have all these underscores I don't want to have all these 720p stuff for any of these I don't even know what this stuff and is in brackets So I want to get rid of it nice and fast. So let's do that in Vim So a couple things you can do Actually, I'm gonna turn on screen key so you can see exactly what I'm doing But first I'm up here in the top left corner The first thing I'm gonna do is delete all of this stuff up until You know the episode number and then I'm gonna replace it with just something like episode So what I'm gonna do is I'm going to go make a visual block and you do that with control V And this you can move around just in case you don't know and of course you can make modifications You can delete what you highlight. You can you know replace what you highlight with C So if I press C and I start typing then I press escape When I press escape, it's gonna replace all of those different lines with whatever I typed So anyway, what I'm gonna do here is I'm going to You know visual block everything then gonna press G to go to the very bottom Then I'm going to let's you know move over word by word till we get to where we want Something like this and once I'm here. I'm gonna press C To replace it and I'm gonna replace it with episode Something like that then press escape once I'm done typing and it's now put it on every single line that I'm modified. That's great So let's see. What else do I want to do now? I really don't like that all these hyphens are here I sort of want to get rid of them So the easiest way to do that in Vim is just with a mass substitute And you actually learn that in Vim tutor if you don't remember, but I'll just tell you how to do it Look down here and the you know command I'm typing so press colon and then the command you want to run is Percent sign s and that's you know substitute on each line then you have a Slash and then what you want to replace so the thing I want to replace is underscore Then another slash and then what you want to put in in place of the underscore and I want to put a space now you have to use a You know backslash or whatever to escape it But I'll just press back splat backs slash and then space and then another Slash and then at the very end you say g and that means not just one instance on every line But every actual occurrence then I run that and you'll see that all of these underscores have been replaced So of course if you're wondering this might seem like oh, I'm doing everything very gradually in actual practice I do this extremely fast in Vim. I'm just sort of explaining everything to you But anyway, so now we're at a point where things are starting to look very clear and good In these file names. I just want to get rid of these like bracket sequences. These are getting a little annoying Now there are a couple ways you can probably do this But I think I'm gonna do it with a macro Now I did another video on recording macros. It's super easy how you do it is first you press Q And then you press any other notice that I'm on the first line by the way But you press Q and then any other key you want to record the macras. I'll record it as D or something like that So now I'm gonna press the sequences of commands I want for the first line that it's going to generalize to all the other lines So first I'm gonna press zero and that's just to put me at the beginning of line just in case I'm not already Then I'm gonna say F Which is find and then left bracket and that's gonna seek the next left bracket that it can find Now I'm gonna get rid of this bracket sequence with delete around Bracket and now all of that bracket sequence has been deleted Now I'm at this empty space. I think I'll press X to get rid of it now I'll press I'm at the next bracket sequence. So I'll press delete around the bracket Now there's one more space. That's actually the space before me. So I'm just gonna press H and X to get rid of it and the last thing I'm gonna do is go down a line And then press zero to get to exactly where I began You know the command in the first place and then finally I'm gonna press Q Okay, and that's it now. Our macro is recorded. So if we want to run it We just press at and D the letter we recorded it as so now the second line The the macro has been recorded on the second line and of course we can press, you know 23 or whatever For all the lines we want to run it on and press it all those times Should have pressed 24 but whatever so now all of the lines have been changed to the exact specifications that we want So yeah, now this looks very clear and readable actually, you know what I think episode is You know a little too much writing. I might actually oops. I might actually replace this with we'll say like E or something like that that's takes up a little too much room So anyway, that's all I have to do now in this. I just save this buffer and asks for confirmation And that's it now all of my files have been renamed. They look very nice now So that's sweet. Let's see if there's any other ones. I can do this on Okay, these Little embarrassed and you know for people to know that I have Carl's that are what is it Neil deGrasse Tyson's cosmos But you know anyway, and I can clean these up as well. Let's say I would just want to get rid of You know, I only want to have the season and episode number. Actually, I should probably do a visual block, of course So I'll just get rid of these again visual block highlighting everything up into this point You can press D or X to delete And then I'm going to do the same out here. So we're gonna have All this and just delete it and that's all you have to do So anyway, I've done this very slow, but just bear in mind when I'm actually doing this at my own pace You know, you get a whole lot of speed And of course, I just changed all of these files at a very abstract level very quickly So you can get a whole lot about a whole lot with this And of course, this goes for any kind of programming you're doing or any kind of modification You're doing at a daily basis and this is one of the reasons where You know why people don't just use them But they have programs like Ranger that allow you to use them to do more and more powerful things Use the extensionality of them to do these things like renaming files So anyway, this has just been, you know, a sort of view into daily life using Vim or Emacs So hope you enjoyed it. So throw something in the comments if you have any questions