 Today, we're continuing our look at Vim and some of the basic functionalities of it. And today, we're going to be looking at tabs and indenting and auto-indenting. So let's start off. I'm going to come down here and add a new line. Now I'm going to hit Tab. Look how far that jumped. So it's like, boo, I mean, that's huge. And so if you're writing code and you've got functions that you're indenting, if you have to do like an if statement inside an if statement inside a function, your code is going to start going off the other side of the screen. I personally, I think most people prefer, most programmers prefer to set spaces rather than tab characters. Pretty much, I think that's the majority, unless you're that guy from Silicon Valley, the TV show who likes tabs. One thing that people do vary on is though is how many spaces. I think the most common spaces people use are four. I like to use two. Four just seems like overkill to me. I think two is just the right amount. So what I'm going to do, again, I'm going to go out of edit mode by hitting escape and I'm going to hit colon. And now I can put in a command. The command here that I'm going to be putting in is basically we're going to be setting some variables. So we're going to set our shift width to two and our soft tab stops to two. And then we're going to expand tab. Those are the commands that I do to cover this whole thing. I'm going to hit enter. Now if I go I into edit mode and I hit tab, you notice it moves not as far as before and it actually is two spaces. Whether you like tabs or spaces, just be consistent with what you do. Because if you use tabs sometimes and spaces others and then you start using a program like Python where indentation is important, it can really mess stuff up for people when they're trying to use your code because you might use tabs at some parts and then spaces at others. But then when they put it, open it up and then their tabs can be turned into spaces and it's going to be a different number of spaces than your spaces. Spaces are a better way to go. Anyway, so again, I'll go over that command again in a minute, but it's set shift with equals to soft tab stop equals to an expand tab. But now we're going to talk about auto indenting. So I'm indented here. If I hit enter, you notice it goes back to the beginning of the line, which is normal for tech setters, but we're writing code. You may want it to auto indent. I'm personally not a big fan of this. And if you're one of the people who come in on my videos that you don't like that I don't auto indent, it's just not my thing. But I'm going to show you how to do it today. So again, I'm going to escape colon to put in a command. And the command we're going to put in is set auto indent. It's that easy. Oh, except for you have to type it right, set. Now if I go back into edit mode and I tab and I type something, now when I hit enter, it tabs me into the same line. And if I was to, you know, now do another tab, you know, for an if statement or whatever, now it's going to follow that tab. So why don't I like this? And maybe, you know, well, one, I'm just used to not, I'm not used to it. So I'm by default, I'm ready to hit tab. And usually what happens is I hit enter and I go tab, tab, and I'm already over. And now I got to go right back because I have auto tabs on, but that's not a big deal. What does, what is a problem is now if I was to highlight and copy and paste this code like so, look at how it all gets messed up because it's adding indentations all the way across. And that is a pain in the butt. If you do like auto indent and you want to paste some code in, what you need to do is set paste before you do it, which is I, and maybe someone in the comments can explain this better to me. Again, this is not a function I use very often. So I'm not that familiar with it. So we have this, what you need to do is get out of insert mode, add in command, set, paste and hit enter. Now when I go, I did it in insert mode, you notice it doesn't just say insert. It says insert paste. Now I can paste things without that happening, but it turned off my auto indent. So, so if I was to be, you know, on this line, I hit enter. It goes back to the beginning of the line there. So I don't see how set paste is any different than changing it to set no auto indent, which is turning off auto indent. Maybe someone can explain that to me. I guess I can Google it. But just so you know, if you have auto indent enabled, when you copy and paste code that's indented at parts, it's going to mess up your indentation. So you have to either turn off auto indent or set paste for your insert. Just be aware of that. And again, I'm not starting to start any battles, you know, I know someone's going to start a fight with me in the comments over, over auto indent and stuff like that. I'm just saying how I like it, but I'm showing you both ways to do it. Now, again, if I was to exit out of this and go back in, all those things that we set, the tabs and the auto indent are now turned off because we issued those commands in a session and we exit out of that session. So what we need to do, if we want those things to be permanent, as we learned in our last video, is go to our VimRC file. Again, that's in your home directory dot VimRC stands for run commands. So these are commands that run when Vim starts. The dot makes the hidden file. So you may not see it depending on how your system set up. Last video, we added syntax highlighting to it. So now let's add in those commands we were talking about before. So we're going to set some variables. We're going to set the width equals to two. That's the shift width, the soft tab stop equal to two and expand tab. And now if you want auto indent enabled, you can just add set auto indent. Now, if we save that, we're going to go back into here. And if I tab, you can see it's doing the two spaces just like we have set. And if I was to paste code, oh, let's first do something like this. Oh, oh, I, I set the wrong thing. I set no auto indent. I'm looking at my normal VimRC file, which is how I have that set. Let's go back into here. So, so we have our shift widths set here, our tab widths and then auto indent. If you want auto indent off, you do no auto intent. Sorry about that. Go back in here and if I come down here and I hit enter, you notice it's auto indenting. And if I was to highlight this stuff and paste it in, it gets all messed up. So that is tab widths and auto indenting. I thank you for watching. I hope you're enjoying this series. Again, it's not for very beginners with Vim and advanced users are probably going, oh, this is boring stuff. But I do thank you for watching. If you're that medium user learning some, some, you know, moving along with your learning of Vim, if you did enjoy this video, think about coming a support over at patreon.com. There's a link in the description, patreon.com forward slash Melix 1000 or you go to filmsbychrist.com. There's a link to that in the description as well. It's Chris with a K there. You can search through all my videos as well as look through all my example notes and also there's a link to a PayPal account there if you want to help support me that way. If you can't support me financially, think about liking, sharing, subscribing, commenting, that stuff helps out. I thank you for watching. And as always, I hope that you have a great day.