Your first VimRC: How to setup your vim's vimrc

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
my name's the prime mission I'm gonna talk to you guys about the vim RC today I know that can be a little bit confusing the first time you look at a VAR c you don't really know what to put in there but we're gonna make the vim RC awesome and so today we're just gonna kind of go over what are some sane default sets you should have how to get a good plug-in manager in there what plugins I find useful and then some remaps that are pretty nice this should only take a few minutes so let's get started as you can see what we have right here is we have this really nice autocomplete menu so I can just jump in here and find out everything that's on there tells me the types all those good things clear and good integration would say a typescript completer a C++ complete or go complete or rest complete all the languages you could ever want not only that but it also has jumping to definition all the good stuff I have quick key presses to be able to bring up the file tree I can search by file right I can go right back to the file that we are I can go to another file right there and of course they also have full project search with rip grep we also have a git integration get lame oh my goodness that's all me if you want them to look like this if you want your vim to operate pretty well where you can jump to definition you can have autocomplete you can have a nice color scheme then you probably need to know a little bit about your VAR c so let's just get started the old fashioned way and of course the old fashioned way is just simply to RM RF your I'll just start by just removing my vim directory and then second removing my MRC right yeah so I've deleted everything from my vim that means nothing works if I jump in here and I try to do an if statement I get no auto indenting I get no syntax highlighting when I hit tab I get eight eight indentations into my tab character it's just kind of some pretty crazed crazy defaults so the first thing we need to do is we need to actually just create and edit a VAR c right so here's our VAR c empty as it gets now i have a set of pretty what i consider some pretty sane defaults let's i'm just gonna throw them in here and then we will look at them alright so now that we have them in here let's just go over them one by one first syntax on just kind of give you some basic highlighting this works with a lot of languages but you may have to download some extensions to make it work with all of them second obviously no air bells I hate sound effects if I go to the end of the line tap stop meaning that it's only four characters long soft tab stop means it's only four spaces long if I shift with means that when I press arrow key over it shifts it over by only four spaces right now I'm still on the previous set because I haven't said anything and still a tab expand tab simply means converted from a tab character to spaces smart indenting means it's gonna try to do its best job to indent for you set line number mean I get nice line numbers no rap meaning if I care if if the line goes off the screen it appears on the next line so instead I want to just go off the screen and keep going so no rapping right smart casing mean that it's gonna be it's gonna do like effectively case-sensitive searching until i put in the capital letter no swap files means that I'm not gonna create those little VIN dot swap files all throughout my project no backup no need no needs people you know why cuz we also gonna keep something like this I can undo directory the undo directory will tell them where to save the directory you have to create that folder so I want to need to do that and then also set undo file means that there should be a file per file that you do and of course my favorite thing in the universe incremental search meaning while you search you actually get results so once again I haven't loaded this file yet so if I were to go like this if I were to go search for set as you can see nothing started highlighting but once I hit enter then it starts moving so let's just source this file right now source % simply sources the file that you have off the RIP once I've done that as you can see you can see the 80 character thing way over here there's my 80 character column you can see that's the color that I guess I chose and now if you see if as I type set you can see that incremental searching so if I start typing in tab you can see that it starts typing the first version of tab Inc search very very nice so now we have some more same defaults also when I do something like if true notice that I get nice indenting it Auto indented for me and it's four spaces which is quite nice which is what I like I know I'm about to get please in the comments below tell me all about tabs and why they're amazing but it's just a little character you could define I'll just finish them I don't care all right now that we got that out of the way that's pretty nice I think those are a pretty reasonably sane set of default that I like to have on all my event experiences and it still has kept our vim file pretty straightforward next so let's just make sure I have the vim fold or deleted I'll just do a little RM RF dot slash bin there we go it's gone the dot vim folder is gone right now all we have inside of our MRC is gonna be what we've put in so far so let's add in that vim folder that vim folders where vim goes and stores everything now notice that I have this right here and undo directory I need to make sure that that is actually created so let's just go make dur vim undo dur I believe - P we'll make it recursive I don't know why - P why not why not for progressive or penetrating I don't know what the P stands it stands for something I'm sure somebody's out there will be a little actually and it stands for pneumonia alright so now that we got that all done we can keep on going so now we have that vim folder created and we also have the under undo directory ready so now all this should start working so the next thing we want is some plugins because honestly vim is pretty boring if you have pretty unreasonable colouring and then it doesn't work on all the files and then you can't do like all the nice things like autocomplete and all that so let's get autocomplete working let's get all the plugins so I've recently switched to plug honestly I can't really give you a solid defense why you should use plug versus bundle other than plug is simply supported it has some post installation instructions that I can run apparently people like it more I'm kind of indifferent personally but I just use it because it's maintained at this point that's like my only real reason to do it alright so let's just get it on there if you look right here here is the bundle or here's the plug-in page it's actually pretty easy of course they don't list any cons right here why would you list cons let's go so I'm just gonna copy this line you should always just copy and download things from the internet because why not it's safe go in there put it where it tells it to notice that it put it inside the dock vim folder auto load plug them alright fantastic alright let's reopen up our vim RC and now let's put in the plugins plugins aren't too hard to do if you look right here here is what plug tells you to do so what I'm gonna do is I'm actually going to go here and search for call plug right here highlight that line put it in here paste it in take out that whatever that was go to the next one highlight it put it in put it right here there you go so now what you have is anything between here is telling plug to do a bunch of installation so the next thing I'm gonna do is I'm gonna put in a bunch of plugins that I think are very useful to have and right here this is my current set of plugins that I use you can go and check out my mar CA on I'll link it down below you'll see effectively these plugins that I use and so let's just go over these a I think it's the greatest color scheme of all time guru box rip prep very fast grep vim fugitive that's the thing that I use to do like get blames or be able to look at differ I get integration a typescript is allowed typescript files to be nicely colored the indenting seems to work a lot better than man man pages fantastic are tags is great for C++ ctrl P for the nice file finding you complete me for auto completing it works in a lot of languages and of course one of the best undo tree so now that we have that we gotta go source that now that we've resourced our current file we now can collect this plug in plug install so once it does this it's gonna take about 30 seconds to go through get everything installed put inside of your vim you can see it right here see how it's cloning in vim plug do you complete me this is just doing a get sub-module an it hey that's kind of nice right little get some module net for you you don't have to do it yourself there you go got it done and looks like it took about 43 seconds so we have those what appears to be about 10 plugins done so let's go and do one more thing that I just think is them just the most bestest of all time let's come in here and let's plug in let's let's set our color scheme right cuz I gotta have that groov box baby but not only do I need groov box I also need the most important thing of all time which of course background has to be dark alright then I'm gonna cut and paste a couple other items to just help make the plugins work these are things that I've kind of learned over the time so this allows our G to always kind of detect your route and to search for the get route and then also use your get ignore for faster searching control P some basic things to help ignore the things you don't want to search for set your leader key if you don't know your leader key is it's the thing that you to enter into your command mode if you are a normal mode where you can you know you can do all your basic command editing you can instead press your leader key then press some other key that you have remapped it'll do special actions I choose the spacebar because it just seems to be the most convenient also these things are for that little file tree I tell it how to open files with brows blue - I tell it no all that extra help information I just don't need it no caching for control Pete tends to be fast enough I still have a weird comment there then I also say let's what is that doing out of order I also put a hey your window size should be about 25% so there we go so now that I have all these in here this should make my editor almost completely usable at this point so there we go once I highlight oh we got that nice goodness not only do we get that nice goodness if we jump back in here and we start editing oh my goodness look at that you complete me didn't work why did that happen let me tell you why that is because if you go to your dot vim folder you have to first go into your plugs folder go into you completely and you have to install it effectively it has to install itself so right now I'm just gonna do the TS completer which is typescript completer so now that I have you completely installed what I can do is I can actually go search around and I can do any sort of auto completing as you can see we have all the nice autocompletes but what I can't do is jump to the definition without inconveniently doing something like this right go to I don't want to have to do that I want to be able to remap it but second if I have to open a window and look at the the file tree at this open up a second split convert it into that it's in conveniently large space so then I also have to go in here and resize it and now I can actually move around and do things inside that tree and then also if I want to switch between these two at the press ctrl W L I want to remap all these things and make them into something faster nicer smoother and filled with coconut oil so let's do that let's re-edit our vim are see them are see and let's go down to the bottom let's add some some nice remaps alright there we go these are more sensible ones now remember that leader key that I told you about this is where the leader key comes in now if I press leader key then H it will execute a window command and then H and so let's first source this so what does that mean that means let's say if I open up a sec window I can now press leader al leader H leader al leader agent I can just jump between them really easily so space al space-age space al space-age very simple and not only that I also have some other things that I've mapped into it I can show my undo trees I can go space you and I can actually see a sweet plug in undo tree or I can see all the different things we've done thus far alright there's me messing up there's me oh crap oh crap oh crap right there's us like three four minutes ago down to here there are seven minutes ago just right there but you can see all the time we were here right before this this is an excellent remap right here what it does is that you can press so leader PV will then execute wind command V which will do what I just did there split two windows and it does e^x which will open the net RW to where we just were and then on top of that it also does vertical resize a 30 which is quite fantastic so that it makes it small so now I have a nice small window where I'm still editing so let's just do that so now I can just press P V space P V and it opens it up right away and my focus over here also we have this PS Project SEARCH I also get rip grep open right away in fact rip grep is fast enough that if I go new dot star WS it should find the only so my entire system where that exists at which is going to be inside the WS folder right there you go it's right inside my little WS folder where I create a new WebSocket framer all right then the best part the best for last you complete me so now what we can do is we can actually just jump to definition so Gd so let's reopen up our file here let's go back to our let's go back to our web socket interface let's go look at what the the URL object is so if I go space GD it's actually going to jump exactly to its definition so now I can simply look at it right here so if I need to jump back and forth between the two it's actually very very easy to get that done and so if you're anywhere else like remember that connect a function that we were looking at if I wanted to go find out what it is space GD I can jump right to it wait wait a second what are the different connection States I can see them right here it just makes working with a code base very very easy so there we go we actually got a VAR c from nothing to something pretty quickly we got some nice the same default sets we have a good leader key setup we have some nice default sets on our plugins we got a plug-in manager put in and we got a bunch of remaps a lot of times how I kind of come up with these different things is that I'll do stuff for a while and then once it starts bothering me I go okay how do I just fix this I don't want to keep on just struggling making something work I know there's an easier way to do it let me go look on the internet like I had control P caching issues I kept not get like I had a file then it wouldn't show up and ctrl P easy fix right there I had problems with rip grep not searching from the root of the project but instead from the file that I was in when I had an older var see that also had auto changed directory on that was very frustrating this simple command works right away for this you know it just this just works you just you just wait till you find a frustrating point and then go and search for it and honestly you can do so much with your vim RC as a kind of a cautionary tale don't let the you know I really try to keep this thing under 90 lines you should try to keep it as small as possible that more grows the more painful it gets and sometimes you'll start getting weird performance issues you don't really understand why and then you have to go play the game of what is the plugin that's causing all the performance issues I can give you a hint it's likely get Gutter get that gutter out of here hey well my name is the prime gen you can catch me streaming on Twitch where I build a bunch of dumb stuff make fun of rust on Python and Ruby and build who knows what come check me out have some fun roast me in the chat the rest the chat I mean they particularly like to make fun of the size of my hands come in say hello tell me my hands are small [Music] [Music]
Info
Channel: ThePrimeagen
Views: 222,996
Rating: 4.9379673 out of 5
Keywords: vim, vimrc, how to, Netflix, vim rc, YouCompleteMe, nvim, neovim, programming, software, software engineering, web development, web developer, programming humor
Id: n9k9scbTuvQ
Channel Id: undefined
Length: 15min 15sec (915 seconds)
Published: Sat Mar 21 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.