Why I Use VSVim for Productivity

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in today's video i wanted to talk about them actually and how i use them for net development specifically in visual studio visual studio for mac and visual studio code um you might ask why would you do that that seems weird and that's what someone who's never tried vim sounds like vim is actually specifically we're talking about vim commands them the text editor no no no get that out of my face but the vim commands how you you know kind of interact on the keyboard with input into the editor is actually very nice and you can move extremely quickly and you can be very efficient and be very productive there's there's really two main reasons why you would use vim for development the first being again speed productivity and and kind of a subset of that is how much fun being fast is it's extremely fun you know i always think back to the first time i ever used the end key on the keyboard to go to the end of a sentence that's not you know it takes you some time to get to that point at least if you're as old as i am and the first time i did that i felt really cool like you know shift end delete hey i deleted a line that's insane um well vim is that times about a hundred so pretty fun so there's productivity side but then there's also the kind of ergonomic side where the less you move your arms back and forth to the mouse or you know off of the home row basically the better you'll experience that a little bit as we go through this but i wanted to make a quick video on describing how to get started with it how you know the basic commands how you can integrate it into your net development because you know as a net developer you may not be thinking about them because why would you but let me tell you it's actually pretty great so let's dig in so the first question really is well how do you use vim inside of visual studio or visual studio code vs for mac the answer changes depending on those the easiest one is definitely visual studio code all you do is you go to the extensions and you search for vim and that should bring back a few options uh the one i use is this one right here it's just called vim it's by vs code vim i believe and it's what it says it is it's a vim emulator for visual studio code and what that means is basically it gives you the options to use bim commands which we'll talk about that in a moment so that's what i use for visual studio code looking at proper visual studio there is an extension if you go to extensions manage extensions and then online and you search for bs bim and you will get this vsvim 2022 that's the one i use for visual studio it provides the almost the exact same functionality as the one for vs code let's talk about this for mac real quick it's pretty different and in fact i actually just got i don't have it over here i just got a new macbook because i wanted to try that experience as a windows person it's been interesting i'll try to talk about at some point as part of that i was installing visual studio for mac and had to go through the trouble of getting vsvim installed which was actually much harder than i thought it was going to be i actually ended up having to go to the github for vsvim and download a package that the creator put in a issues thread and that finally got me there but downloading from the main releases and things like that would not work so just let you know if you're on a mac and you're trying to do this it may be a little trickier i might put some information in my comment down below to kind of help with that but anyways just to know that okay so now you've got those installed let's dig into what is vim let's talk about them in general for these extensions specifically i'm not really talking about the editor itself so just if you want to use that editor go for it but something i'm talking about here them for visual studio the main thing you need to know is there's a few modes specifically the two most important ones are what's called normal mode and insert mode normal mode provides all kinds of movement abilities with your keys so for instance if i'm in normal mode which you can guarantee that you're in normal mode k move up and down h which is right beside j moves left and l moves to the right so you're kind of you're moving around with that row if you want to quickly move around i would highly suggest if you've installed the extension you just you just get in there and you just press j and k a bunch because it will kind of get you used to that movement and kind of show you how kind of nice it is to move with those keys instead of moving over to the arrow keys for instance because that's a that's an arm movement that's what we're trying to avoid so k and j to move back and forth just know that that's going to feel weird at first and but you'll get used to it that's why i suggest just getting in there and doing it so your most common commands you're going to use are obviously jk h and l though i don't really use html that much because there's faster ways to move around let's talk about there's also u for undo which a few minutes ago i deleted this line here because it's not actually valid i don't know why i was in the source so i'm going to delete that line with dd we'll talk about the second but if i press u it undoes it so u will undo it's it's just like doing control z in windows for instance so you undo so if you ever mess something up just press undo so if you want to move more than just one character space at a time even up and down there's some keys you can do so w will move you to the next word how does it define word that's usually a symbol or a space so for instance if i press w here it'll go to clickable pin if i press it again it'll go to the end of that to the next symbol which was a curly brace and then if i press b it'll actually go kind of backwards that way so it's the beginning of the previous word w to go forward b to go backwards by a word so you can see that that moves much quicker if i just hold w you know go pretty fast if i hold b i go fast the other way so that one's good there's also e which will take you to the end of the word so that's pretty useful you can just kind of spam me so uh the main way i use these is in conjunction with another mode and it's called visual mode so if i press v lowercase v and i will say all these commands are case sensitive because the uppercase or lowercase versions of them do different things so if i press lowercase v you can see down there right here i'll hopefully zoom in on the video a little bit it says i'm in visual mode and so what that means you'll notice if i move now i am highlighting things and it's kind of a way to do a large selection doing lowercase v will do individual characters at a time but if i move up and down obviously i can do full lines but also there's shift v which will do the entire line so you can shift v highlight you know these two graphics views and then you can do something do them so you know like earlier before i press d d to delete but right now since i have these highlighter press d they're gone then i can press u to bring them back so hopefully you're starting to see some of the power here um so for instance let's say i wanted to delete these and i'll say if you press d to delete something it's not permanently gone it's actually on your it's kind of a type of clipboard your yank clipboard or something like that i think it's called so right now if i press p it'll actually paste what i had out there so again i can highlight these press d move down and it'll if you press p it will paste to the line below where your cursor was if you do shift p it will place to the line above where your cursor was okay so that's paste p for paste that one's pretty easy d is for deletes and again d once puts you in a delete mode and then d again will delete the full line okay so dd to delete a full line that's one of the most used things i do you can press zero to go to the beginning of a line and dollar sign to go to the end of a line if you're trying to do movement though i will say i i use that one sometimes like if i'm trying to delete till the end of the line or something i'll do that but a lot of times i just do shift a just to move me in the line and also put me in insert mode a little quicker okay so those are some movement commands but let's talk about insert mode so insert mode is the other kind of mode you'll use the most so if i press i it puts me in insert mode you can see my cursor is now the kind of vertical bar instead of the full character size and what that means is i can actually type so this is me typing visual studio is going to help me out because it clearly knows i meant is enabled all right so now i'm in insert mode to get out of inside modem back into normal mode you'll press escape and then i can press for instance v bb bbb delete to delete what i inserted so that's the other kind of mode you'll use the most is insert mode now do note when you're in insert mode you can't type jnk to go back and forth you can actually type it that's the point of the mode is to type the other kind of mode i would say it's not really a mode kind of a mode is if you press r you can replace a character so i can type t here and i replace the g with a t and then the kind of mode of that is if i do capital r i can type the full thing and replace the whole so like if i type trabfix you know uh you're replacing as you're typing i do use that one every now and then uh it's actually pretty nice if the word actually fits what you're trying to do which i'll admit it's kind of rare but so r to replace shift r you know capital r to do a replace mode that will continue until you press exit okay and back to insert mode type stuff another one i use a lot is if i press shift a you know capital a it'll put me at insert mode at the end of the current line that one is obviously very useful if you're trying to say you know put a semicolon at the end of a line you can press that and then semicolon okay and one more other kind of useful insert mode type trick and one that you definitely need to know is the letter o so it inserts a line and puts you in insert mode below your cursor and i believe capital o is above your cursor so pretty nifty there i use that all the time so another i mean kind of back related to the replace command is there's s and c both of which do sort of similar things so if i do the letter s it will replace what i was you know what i had selected and put me in insert mode so it basically deleted the character i had and put me in insert mode uh which is cool if i do so for instance i guess i could do like v e s and it deleted the line and put me in insert mode sort of related to that is the c which is basically just it's going to delete whatever i give it i type c and then e it deletes to the end of that word stuff like that so that's that one's pretty useful too just delete the the point the thing is though you have to trust it to know where the word is if you're trying to do that but you know like for here this one's pretty easy there's a space so it'll know where to go all right so uh let's see what else oh you can use tilde to convert the case of a character so if i press tilde it made it lowercase you can see the g became lowercase if i press it again it makes it uppercase so if i get a whole word i can just do that and it flips the case pretty nifty there's another uh type of command the the period and i'll just say there's a million of these i would highly recommend as you're learning to use vim to have a vim cheat sheet open i'll put one in the description below that i use because you will forget these you 100 will but the important thing is to know they're there and then incorporate them into your workflow so you can be more productive using bim this other one i want to talk about is the period key which redoes what you just did so for instance if i did till daytill day two to the till day then press period period period period period it redid the last command the last tilde command it's kind of the opposite of undo basically so if i did dd for instance then i press period it did a bunch of dd's and then you to undo them again okay so probably the only advanced thing we'll talk about here this is kind of a getting started video but i want to show you these because i think they're very cool i haven't really incorporated them into my work much because they're kind of complex and you have to think about them a bit but what i'm talking about is macros so macros are pretty cool basically you press lowercase q and now i'm in like a macro mode so any keystroke i put in will kind of be recorded so once you press q the first thing you do after that is you give it a letter to bind the macro to so what i do oftentimes is a capital w so now i have bound the macro that i'm about to record to capital w and then you just do a sequence so i'll do um let's say www w tilde tilde tilde field tilde down to left to shift v uh build day and then you press q to finish the recording so let's see it work so the way you use it is you do at sign and then your saved letter so i just did it it did exactly what i told it to so if i go back up here and i do at sign w again it did the exact same thing i thought i told it to do down below it pressed the exact same sequence so that's actually useful if you're for instance coming in here and let's see if i have one okay so let's say for instance i wanted to record myself putting a semicolon at the end of this line and then coming to the front of the line and tabbing it twice whatever someone press q i'm gonna save this to one and then i'm gonna press a semicolon escape zero insert tab tab escape queue okay so now if i come down here and i do at one it does it for me f1 at one at one at one there you go that's that's a macro they're pretty useful you know you kind of have to be thinking about it also this is f sharp code so there shouldn't be semicolons in here so i just did a very dirty thing all you f sharp people i'm very sorry i did not mean to put semicolons in this code but anyways yeah so femme very cool you can be very fast with it i'm i'm honestly not that fast with it i've seen people are much faster but you know it's pretty fun pretty useful another one i'll just throw in real quick i do highlighter section i press shift and then uh brackets so for instance i do that way it indents boom move the whole block when dense pretty cool yeah so that's bim i just wanted to make a quick video on it because i wanted to kind of i guess for one thing show that i think it's worth doing and i think it can make you a lot more productive and you know i think it's really fun i think the commands are really fun all the haters out there keep hating that's fine we don't need it i'm just going to sit over here and try to think of macros for 10 seconds every time i try to do an action definitely won't slow me down so uh anyways hope you enjoyed i will talk to you next time bye
Info
Channel: Programming With Chris
Views: 8,681
Rating: undefined out of 5
Keywords:
Id: qPyv6_iRsWc
Channel Id: undefined
Length: 15min 10sec (910 seconds)
Published: Mon Aug 15 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.