 Hey everybody, welcome back to the channel. Working on increasing and improving the production values here on the channel, so bear with me. The audio should be a little bit better this time because I'm recording it separately, but we'll see how it goes. Anyways, great start to a video, right? Today we're going to talk a little bit about splits in NeoVim, or this will also work in Vim, this will also apply to Vim, but we're going to be working on the NeoVim config we've been building from scratch for the last few videos in this series, and we're going to be doing it in Ubuntu. So let's go ahead and switch over to the screen here. All right, so I've cd'd into the nvim configuration file, or directory, and basically what we're going to be doing is talking about splits, and how to manage them, how to make them work better than they would in default. So splits are something that will work out of the box in a certain way. So if we just open up Vim here, oops, I keep forgetting that I don't have my aliases here, so in Vim, we open up this, and we close a nerd tree because we don't need that, and we just type in vertical, I think that'll work, oops, must be vs, yeah, there we go, that's what a split looks like. And basically it just allows you to use these two Vim windows as if they're one. So it also allows you to yank text from one split to another, delete things and copy them into the other buffer. And that's not something you can do if you had, so let's say you close this out. Wow, Ubuntu sucks. Let's say you close that out, and you had two, oh, I miss, I miss having key bindings. Anyways, if you had two, and you had, you couldn't easily copy text in between these two unless you had specific like X clip or something set up in order to do so. So it also helps you when you want to just have two similar files side by side without having to have multiple crappy windows open up like this. Oh, because I have a talk about not responding. Alright, anyways, so let's go ahead and talk about how we can make splits better because the way it works out of the box are some really weird key binding Sophie CD into dot config and them and CD into bindings and S and them key bindings. Okay, a little bit smaller, so it actually doesn't take up the whole screen. Right now this is the only key binding I have changed that that's that just toggles nerd tree. Um, by default, if I were to open up a vertical split here, it would to get back and forth between these two, you have to do control w and w again. That's very intuitive right control w and then w again, control w w again, that is trash. So let's troll w w again, oops, control w w again, and we just quit this out. And that's not that's just not great, right. So the first thing I would change, we'll just create some lines here because we want this above is, and I'm just going to copy and paste this, these will also be in the description. If we just control the end of these. So basically what this does is is changes control w into just control J, K, L and H, these are just the them keys. So if we write this, and we troll out of this and then just go back into it again. And we open up others vertical split. Now we can press control J or H and L to go back and forth. There's no weird extra key that we had for ease. You can see how I'm switching back and forth with the how the cursor switches back and forth. See this? Oops. And that's just back and forth. Now you splits don't have to be vertical, they can also be horizontal. So if you just type split, I think this is the way. Yes. And see, I know I haven't over one like this, and I can move up and down by J and K. Now, let's say I wanted to open up a specific file. So let's control, get out of some of these. Let's open up a vertical split of that config. So till the slash.config and them general settings up. Okay. And that just takes us into our general settings config file. And now we have both of them open at the same time. Very easy, right? Now, hold on a second, I have to cough. I've been doing that a lot lately. It's just a cold. I'm okay. Anyway, so let's say we wanted to do change the, how much one of these splits takes up on the screen. So you can, I believe, take this and drag it. But we're not Neanderthals here. We don't use mice. We use key bindings. So if you want to increase the width, you have to do control w and then the pipe symbol. Maybe that's, that increased the width a little bit too much, I believe. Because that's still there. Control w and then the pipe symbol actually makes it take off the whole screen. I did not know that. I never use that. But that's the way that works. You can also, let's say you've done that, control w and then the pipe symbol. You can get it back to normal by pressing control w and the equals sign, supposedly. Oh, that's because I'm done. Control w and then equals. No, that still doesn't work. Control w and equals. Yeah, there we go. There's how to have it. That's, as you can tell, that is also a horrible way of getting things set up. But I'm not, I've never gone through and rebinded those because I don't use those that often. Because when I do this, let's, let's, let's get out of this and create a new vertical split. So let's just say we want to create a specific size when we open this. So if we do a 40 vs and then a dot till the slash dot conf a oops, can't type. As you can see now this took about the main window take up 60 and this took up 40. And you can do that when you're, it's just so the 40 is the percentage of the screen that the new split will take up. So if I could, I could control quit out of this again. And oops, I could quit the wrong one, but it doesn't matter. We just do say 10 vs till slash not come fake and see that and that took up 10% of the screen not obviously that's unusable, but it's, you know, there, and then you can control w and you know, the there are other bindings that I don't have written down in my outline that would actually go through and make make this, you know, usable that because that control w pipe sign is is a dumb is a dumb thing, but you get the point. I will also include some links where you can find some other bindings that are basically unused. So let's say I want to swap the left and right. Let's say I want to switch these back and forth. They're the same file right now. But let's just say I wanted to do that. So I do control w and then capital R. Let's actually open up a different file. So let's see 30 vs dot till the slash.config and then key bindings. Okay, so let's say I want to switch these back and forth is control w capital R. And that switches the place. And it works with the horizontal split as well. So let's just say I want to create a split of, I don't know, till the slash.config and then in it RC and it not then. Okay, and then we can do control w R capital R. And that will switch them back up and top. So that's how those switching, you know, you can break. Let's just say we wanted to make this one here, this bit, oops. Oh, you tell I don't use Ubuntu. Oops. And I pressed type the wrong password in. Okay. Super L locks the screen and Ubuntu. The more you know. Anyways, let's just say we wanted to go through and make this main one here. Full screen, but I didn't want to lose the other splits. We can do control w capital T and that breaks basically breaks it out in two tabs. So you can our other two splits are still here. But in this buffer here is now full size. And let's go ahead and close this out. Let's just say we wanted to keep. Let's say we had another vertical split and another split here and we had all these. So we wanted to close every split, except for the one that's active. So we do that by control w and small o. And it closes the rest. Now remember, that doesn't automatically save. So if you have work in those other other splits, you have to save them first. You can also obviously save them, save things by doing shift is easy, or colon WQ or any of the other innumerable ways you quit out of them. I mean, there's just so many different ways. Alright, so where do you find all this stuff? That's the question. So if you do colon help and splits, this will bring you to the splits help page. And there are a lot of a lot of different lots of different information that you can get out of this. It's it's a very actually long thing. And I'm not going to go through the whole thing because you can get to this and just read it yourself. But it'll also show you how to do several different things. So we will quit out of that. And we will get out of them completely. Now let's just say we wanted to open up a split from the terminal itself. So we can do that by doing n them dash. Oh, I believe this will do vertical splits. I'm not sure which I can't go. That's first of CD into a level. So and then dash. Oh, and then we want a knit them and slash general and settings them. And that should open up if I've done this right. It in a horizontal so small O does it in horizontal splits. So we did get rid of nerdy tree and you can see we got a horizontal splits. Let's close that and do the same thing. But with a capital and that gives us a vertical split. And again, just close the nursery and we have a 50 50. That's how you can do. You can open up splits, two files in splits directly from the terminal. And that's something I didn't know until I looked it up. Now one of the things. Let me see if I can find this again. All right. So let's just reopen this up here. Okay. And we'll close one of these. If you notice when you open up a vertical split of let's just say general and settings. If you the way splits usually work by default, the new file that you just opened up will actually appear over here. But that's not really all that great. So basically what you want to do is in your standard settings file, you want this line here, set split below split right. Basically what that mean is any split that you open will automatically have appear on the right side or the bottom. Instead of the default behavior, which is the left side and the top. Now, if that doesn't bother you, you don't have to change it. But for the most part, especially in English speaking places, people read, you know, left to right. And things peering on the right, you know, or the left or whatever. It's just comes across a little awkward. So the last thing I want to talk about was the two commands in here just real quick. So if you do, you notice how I did VS. You can also do VSP, which is the same as VS, or you can also do SP, which is for horizontal. And then it's just the syntax is just a is just add the file name you want to open up in the split. And that will open up the file. Now, if you leave no file, it will just open up a copy of the file you're already viewing. So remember that whatever one you're working in, you'll need to make saves changes to that file, not the other one. They just open. Otherwise, if you have two that are exactly the same, but you've made changes in one and not the other, you save one and not the one you actually made the changes in, it can get messy and makes you start losing things. So that's just the very basic things that splits can do. In another video, I believe the next video in the series I'm going to do, I'm going to talk a little bit more about key bindings, and I'm going to do a little research on how to because there are better ways to change the sizes other than that weird control W, you know, underscore thing, which seems to make the focused split 100%, but leaves the other one still there, which because I mean, this lets you move between them, but you can't use the top one because it's barely visible. But I'm going to do some research and see how to change those key binding because I've only done it once in my own. And I can't quite remember how I did it because of course I stole it from somebody else, which is the way things work on the internet. I mean, obviously, anyways, I will leave the link to a couple of tutorials that are really good to have all these key bindings in them in the description. I will also leave a link to my GitHub repository where you can find this work in progress made from scratch and them configuration so you can download it yourself. I know I this is me being hypocritical, but I would go through the way we've been doing it and follow these instructions and build it yourself. You'll feel better about it because I use for my main configuration file, I use somebody else's and I get confused a lot because it's not, you know, it has different, you know, key bindings that I'm not used to and I have to go through and search it through stuff. Anyways, but that's up to you. Anyways, I'll leave those links in the description. Thanks for watching. I'm using OBS, so I'm a little, normally I use some screen recorder. I've moved up in the world, so I hope you like the slightly better production values. And if you think that I should start using a camera to show my face on these things, let me know. I do have a camera, I'm just a little camera shy. Let me know in the comments. Get a subscribe, thumbs up, thumbs down, all that stuff. And thank you for watching. We'll see you next time.