How vim Makes my Daily Life Easier

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so if you're a normal person and you hear people talking about them or Emacs or all these expensable 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 the little optimizations you can get from them you know just from playing around with it just like in the day by day stuff you have to do so today it was a little bored so it's 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 are some some names that are sort of you know all jumbled up and I'd like to have my filenames nice and good-looking and stuff so in this video I'm going to show you what them can help me do you know just renaming files and math 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 them 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 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 or any of these I don't even know what this stuff 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 going to turn on the 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 going to do is delete all of this stuff up until you know the episode number and then I'm going to replace it with just something like episode so what I'm going to 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 in press escape when I press escape it's going to replace all of those different lines with whatever I typed so any what I want what I'm going to do here is I'm going to you know visual block everything then going to press G to go to the very bottom then I'm going to lets you know move over word by word till we get to where we want something like this and once I'm here I'm going to press C to replace it and I'm going to 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 modifying that's great so let's see what else so 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 % 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'm going to put a space now you have to use a you know backslash or whatever to escape it but I'll just play press back splat backslash and then space and then another slash and then at the very end you say gee and that means not just one instance on every line that every actual occurrence then I'll 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 them 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 a 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 of it 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 macro as I'll record it as D or something like that so now I'm going to 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 going to press 0 and that's just to put me at the beginning of line just in case I'm not already then I'm going to say F which is find and then left bracket and that's going to seek the next left bracket that it can find now I'm going to get rid of this bracket sequence with delete around bracket and now all of that bracket sequence has been deleted now I want this empty space I think I'll press X to get rid of it now I'll press I'm up the next bracket sequence oil press delete around the bracket now there's one more space that's actually the the space before me so I'm just going to press H and X to get rid of it and the last thing I'm going to do is go down a line and then press 0 to get to exactly where I began you know the command in the first place and then finally I'm going to press Q ok 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 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 clips shader to prosper 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 groups I might actually replace this with will 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 saved this buffer and asked 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 ok these little 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 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 I'll tear so we're going to have all this and just delete it and that's all you have to do so anyway I've done this very slow is 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 we're 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 is just then you know a sort of view into daily life using them or Emacs so hope you enjoyed it so there's something in the comments if you have any questions
Info
Channel: Luke Smith
Views: 284,362
Rating: undefined out of 5
Keywords: vi, hack, luke smith, mac, podcast, macos, emacs, extensible, gnu, terminal, gedit, programming, easier, windows, editors, vim, life, hacking, tui, linux, not related, living, easy, nano, text, tty
Id: NzD2UdQl5Gc
Channel Id: undefined
Length: 8min 30sec (510 seconds)
Published: Wed May 24 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.