VIM Movements P2: 5 moves to make you better ked

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
my name's the premchand welcome we're doing another VIN video now this is gonna be a special video this give me the five moves to get you better at them slips teen your game L classic I need to step it up I need to hit that VIN Jim and tonight oh we're going there so let's do this [Music] now here's the thing is that there's not just five moves that are gonna make you go from just just really really mediocre to just fantastic it's gonna require you to do diligence theory I mean you gonna have to get after you're gonna have to want it I can help show you paths to take but you're gonna have to do when you mess up and you don't do it the most efficient way I want you to redo it that's what I've been doing it helps me learn it helps me internalize it just keep on making myself do it the best way that I know how and you will get faster you will get better so let's go you don't look beat around the bush here these things aren't easy I get it are not easy but you gotta want it so we're gonna do that also at the end of this video I'm gonna show you my favorite memory map I've ever done it's very exciting but without further ado let's get started number five number five I put this one on the list because this is just been it's it's like my staple it is the one that I use the most and that is because I don't have to use the Escape key so what I use instead of the Escape key is control open bracket a reason why I like using control open bracket is that it allows you to escape without pressing the escape key you can also use control C I kind of go back and forth between the two control bracket seems to be the most supported it also allows for vertical editing it is pretty nice and then second the reason why this one is so good is that you don't have to have your caps lock key remapped to escape I mean that's all oh that just sucks you're you're losing such a good key for something that only works in vim control is so much nicer there because at least you can do some more stuff right and so I just love the fact that I get my caps lock key back and especially since I use a special keyboard I can just do with a single hand motion and boom right back out and I can keep on going makes it easy to move around all right number four now number four is it very specific you can only use it in some cases but when I found out you could do this I have never been I've just I've never been so proud so we all know what F and T does right F jumps to a character T jumps right before care so if I go fo but really I actually wanted like the Oh way over here right way over on that position well that kind of sucks please I have to go fo fo fo-fo well no we're not gonna know there's a better way you can go fo and then you can press cent or a semicolon semicolon semicolon semicolon it will repeat your fo and if you press comma it goes backwards and the reason why that is so amazing is so personally I just hate having to press capital F I don't know why that bothers me it just bothers the hell out of me so I can press F capital C comma and go back so I'm still using all the same search semantics that I'm already used to comma close backwards salmon colon goes forward and I can search back with F and T without having to deal with pressing capital F or capital T I know little nitpicky but I just love it and when I learned about this it blew my mind number three man we're moving fast we're already to the middle element of our list you know we go fast in this channel without further ado what is number three number three is C not D that's right so what does D do well D Dilys right so you can do your D your F and your T's and all the different things you can do with D but you can do the same things with C now let's do a little example right here so I have this little event dot type is equivalent to event type screen changed right so what happened if I do this Ivan if I delete it with DW and now I want to change it at the press I and then at the press control a bring up an autocomplete and I'm at the hop around I guess ws binary I could have typed it if I knew it but weapon if I didn't know it I'd have to pull up that autocomplete either way I have to press a lot of keys to get to this point so let's redo this but with CW so I'm gonna press CW yeah notice I didn't press I I didn't press control space I didn't press any of that because it does it it sends the right signals and things work well with it n I'm RT and insert mode which is fantastic and yes that is Dvorak if you're wondering all right number two now number two is just the most mind-blowing the most of them gasma cover ones list but it's still not number one I know crazy right what is it it's AI na you mean like insert and insert after get him out get him out so I and a yes I and a so remember see that we just got done talking about let's use that together right cuz C D and V work very well with AI and a so let's go over it I'll use V to begin with because V highlights and it will kind of show you what I'm talking about so let's go like this VI opening parenthesis or closing parenthesis doesn't really matter you can use either or it will select between that group I means inside of the group a means on the outside of the group so notice that my highlight is before the opening print or it's after the opening parenthesis before the closing parenthesis if I do that again and do V a opening parenthesis you'll notice that it actually takes both the parentheses on each side as well if you're right here you can also do the exact same thing with VA opening squirrely brace it will cover that whole block it's effectively in between is how I think of it and you can use it with addy so if I just want to delete this if statement I'm somewhere in between the if statement right I just like this di squirrely brace just deletes it but it gets even better if I use CI swirly brace not only does it delete it it will put my cursor into the correct spot and I'm in insert mode all ready to rock and roll see I and a is mind blowing and in conjunction with see just delicious and it also works with quotes ticks brackets it works with everything it is fantastic number one I know you're probably wondering what could get any better than all these this one's a tricky one alright because a lot of people have used it before and hated their experience it's mostly because you used it wrong I'm convinced you've used it wrong what is a mark a mark is the is a point in code in which you can jump to they can either have it unique for a file or across the files if it's across the file obviously you can only set it once then you jump to that file if it's unique to that file you can say have the same jump to letter in multiple files so let's kind of go over that so I personally only use cross file jumping I do not use local file jumping I find that a little too cumbersome all right so I'm about to write a unit test and this is kind of like my primary file that I'm working on so I'm gonna set a marker right here I'm gonna like this M shift J this is shift J for you not for me I use Dvorak like you know not like a pleb so shift J for you plebs out there and so what this means is that when I press comma J I'm gonna jump to this point so if I'm right here and I press comma shift J I jumped right here right so comma capital J which means no matter what file I'm in if I jump somewhere else and I press comma shift J I go right back to that point which is pretty nifty so this is my primary fire I'm about to write this unit test but I need to go add some utility functions I'm gonna jump over here to a utility function file and I want to add something write export function you know something right but I don't what what what do I want to put here hmm I don't really know so what I'm gonna do is I won't go like this I'm gonna press M shift K I'm gonna put a nother mark as my secondary file so now if I press single quote J I jump here single quote K I jump back I can jump back and forth with this now you're probably wondering why not just use you know control I control oh the problem is if I move around a lot in a file control I and control o get quickly polluted with just a bunch of other steps I do not want to do it I also navigate using open and closing squirrely braces which are also stored to your control I in control oh that would make it really inconvenient and then sometimes you get so determined that you're gonna make that control I or control o work and you're pressing back like 20 times to get to the file that you want to get to instead you can just go like this single quote shift J I'm back to exactly where I want to be that means I can go in here I can add the file I can jump up top I can jump down here add that exact little function right here jump once again to my primary 5 so everyone jump to mice I want to jump to my secondary file and I want to take in a you know a count right Ryan let's return count times 10 right Oh almost made it 100 I can just jump back to my primary file oh no I haven't added it there all right you're right I want to do this but actually I want to say how much it's multiplied by so I'm gonna do right here that I'm gonna jump back to this one uh you know there you go let's see times but you know what happen if I don't want to have to provide that argument right so like I can jump back and forth really easily but I always have my primary file to go back to so as that utility function doesn't become useful anymore well then I can just change that mark out for another one but I always kind of have home base as my primary file that I'm working on and I think that that is the best way to use marks and marks saves so much time and so much overhead because you just you're just mapping the files that you want to the fingers right it just makes it so fast at navigating so those are the top five moves I think that you need to get better at all right those moves will make you such a fast vim wizard and that if anybody even watches you use vim they're gonna just think you're amazing so I promised you a banger of a remap well let me show you what that is all right so I want to take this position component and I want to get it outside of this if statement right I need to use it somewhere else so what do I do well I give it the old vajayjay right little shift vjj the vajayjay paste it up here we highlight it format it maybe put a little bit aligned a little bit of clean up in there and boom boom save twice because I'm paranoid and we're good to go right we've all done that we've all done that a bajillion times well here's the deal there's actually a better way at least with short moves so instead what I'm gonna do is I'm gonna give it the old vajayjay one more time I'm gonna hit shift K okay and I'm gonna move the thing up as you can see I can just simply move my highlighted region up or down and it will also format that highlighted region for me so that it fits the proper indenting all right so how did I do it well here's what I did is I used this v remap right here to be able to do that I use the Move command along with using a highlighted range either end or beginning and along with that using a +1 or negative - yes negative - to go up once there you go and then of course right after I get done doing that I do GV so what does GV g fees pretty neat so if I do this accidenti V Erie highlights my past highlight and then oppresses enter to reformat and then it reheats G V again so there we go that's how it works so when I press down down down it reformats or it rehires repositions and reformats and then re highlights again and there you go just I just want to find a reason to use it it may not even be that efficient it just feels really good to use my name is the primes and thank you so much for watching this video hopefully these top five commands will make you sweaty or at them will make you just fantastic at them and if they are difficult keep using them keep getting better if you use like D W than I undo it and read and just do it with C W you just gotta focus and you just gotta get good and you just got to redo it if you mess up honestly if you get good you will be happy so get good kid we got this together I stream on Twitch if you want to come check out the channel we build a bunch of dumb stuff including orphan royale the two greatest programs ever written until next time just put in like a joker something but what a good ending in alright I'm not I'm not in charge of your endings just put just put a good ending in make it happen take them just take my awkward self out and put something good in [Music]
Info
Channel: ThePrimeagen
Views: 36,594
Rating: 4.9420691 out of 5
Keywords: software, vim, programming, javascript, typescript, software engineering, web developing, web developer, software developer, developer, cpp, programmer humor, humor, reactjs, js, ecmascript, tc39, Netflix, Engineering, Engineer, Facebook, Amazon, Interviews, Software Interviews, vimrc, neovim, spacevim, vim c++, vim editor, text editor, vscode, vscode vim, vim plugins, coc.nvim, autocomplete, vim autocomplete, nodejs, twitch, stream, developer productivity, spacemacs, emacs, bash
Id: QN4fuSsWTbA
Channel Id: undefined
Length: 12min 57sec (777 seconds)
Published: Thu Apr 09 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.