 Okay, so one of the requests I get most often is to do a VIM tutorial for basic users for beginners who have never used VIM, they've heard about it, they know stuff about it, maybe they know what's out there, maybe they've been told to fear it or told that it's hard to exit or something like this, an instructional for someone like that who wants to learn VIM. Now, every time I get a request like that I've pretty much always said the same thing and that is open up a terminal and open VIM tutor and VIM tutor is exactly what it sounds like. It is a tutorial for VIM, it is a VIM based playground for you to learn VIM in it. It's fantastic, it's where I learn VIM, it's where many other people learn VIM. Now maybe that's not enough for you, so in this video I am going to reach you halfway. This is going to be a, it sounds silly, but a VIM tutor tutor or a VIM tutor commentary I should say. In this video I'm going to go through, it might be a series of videos depending on how long it is, but I'm going to go through VIM tutor myself. I'm going to do all the commands, learn all the basics and I'm going to give you all of the extras because VIM tutor is fantastic, it tells you all the stuff you need to know to basically use VIM, but there's a lot of stuff it doesn't tell you. There's a lot of stuff it doesn't go into. So this video you can watch while doing VIM tutor yourself and pause it when you need to. I'm going to be going through all the basics, I'm just going to be sort of breezing through it so feel free to keep it open and pause it when you need to. Now to open VIM tutor, all you need is to have VIM installed, open up a terminal and run VIM tutor, easiest thing in the world. Now the one thing about VIM you need to know that we might explain at the very beginning is VIM is what's called a modal editor. Now most text editors when you get into them and start typing keys you expect it to modify it's like to actually type those keys and the thing that confuses people who use VIM for the first time is that when you just start typing keys in VIM it doesn't do what you expect it to do and that's because VIM is a modal editor. Now let's explain what that means. VIM has two main modes, there are many other modes but two main ones. There's what's called insert mode and insert mode is when you are actually typing what keys you press. Insert mode is normally how you actually type your document that's you know if you open up notepad on Microsoft or in Windows notepad is sort of like always in insert mode right. So VIM has that of course you have insert mode but you have another thing called normal mode which is the default position in VIM and it's really what you spend a lot of your time in when you're actually using VIM and normal mode is of course you could really rename it shortcut mode. The way to think of normal mode is every key all of those keys all your quoted keys are different shortcuts that mean something and knowing VIM is knowing those shortcuts that's really all you need to know conceptually about VIM but let's go ahead and get into it. Now once you open VIM tutor you'll start here. You shouldn't be using your mouse and you shouldn't be using your arrow keys but you learn your very first key here and that is J. Press the key J or the J key enough times to move the cursor so that lesson 1.1 completely fills the screen. So I am going to press J a whole bunch of times to scroll down painstakingly one one line at a time and now we're at lesson 1.1 okay moving the cursor now VIM is known for H, J, K, and L which are keys right on your home row right H, J, K, L. Now H, J, K, L are the arrow keys in VIM so you know J of course is down K is up L is right and H is left and that's of course going to be a little counterintuitive if you've never used something like that. I mean you might be familiar with WAST or something like that but H, J, K, L is VIM's way of doing directions and it's a great way of keeping your fingers not just on the keyboard rather than having to go to your track point or mouse or something like that. It's a great way of keeping your your fingers exactly in between at the home row where they need to be and where they need to be to press other stuff so it makes for getting things done pretty quickly. Now so we'll play around you can play around with H, J, K, L. Now let's go down to the next lesson so this is how to exit VIM because this is the thing that confuses people and they're all a bunch of memes about you not being able to exit VIM when really it's lesson 1.2 so it's the easiest thing in the world to do. Now exiting VIM they tell you to use colon, queue, exclamation point and inner. That's a lot of typing it might seem. Now what you're doing here is when you press colon you're going into a kind of command mode when you can type a command down here and run it. Now queue is actually just an abbreviation of quit and if you run quit it's going to quit. If you run queue it's going to quit. Now the exclamation point I should say if I scroll back here the exclamation point is basically like no confirm so you have made changes to a document and you just type in queue if you run the command queue it's going to say do you want to save your you know changes. If you run queue with exclamation point that just assumes you're not going to save your changes that's what that means. Now I think that colon queue exclamation point inner that is too much typing for me so I'll go ahead and tell you one nice way the way that I usually quit Vim is I'm actually going to turn on scroll lock for people capital Z, capital Q and when you do that you just automatically leave Vim so capital Z, capital Q that does basically the same thing. Okay so let's go back down here. Now exiting Vim we know how to exit Vim capital actually I should probably say it since I just used it. You can use control U and control D to move up half page at move move up or down half page at a time. Now U is for up and D is for down of course so control U control D these are general Vim shortcuts I use them a good bit so since I'm using them I might as well tell you they're not actually included in VimTutor despite the fact that they're pretty useful. Let's talk about something else I don't think that VimTutor talks about because these are easy to remember. If you type capital L this will send you to the bottom of the page. So capital L sends you to the bottom the low portion H, capital H for high sends you to the high portion of a screen and capital M will send you to the middle. So you can use something like control U and control D and then use M and L and H to get wherever you want on the screen or something like that. So those are easy to remember. Control U, control D they're just up and down and H, M and L they're just high middle and low. Very easy to remember and I'll give you one more one that doesn't have a mnemonic with it but one more thing to remember is if you're on this line and you want it to be centered you can just type ZZ, lower case Z lower case Z and that'll get you on whatever line you need to be on your cursor is on. Okay so less than 1.3 editing text in a very basic way. So this is going to give you deletion. So you learn that Z or excuse me X is the character for just your typical deletion of a character and it tells you to go move the cursor to the line below marked with the arrow so we're gonna move it down here and then you can go over to the superfluous characters and delete them with X. So I'm gonna delete those the cow is over the moon. Okay very simple. So now that we have that that's simple enough that's how to delete one character. Now of course in Vim if you want to delete a whole word you're not gonna type you know XXXX that's not how it's gonna be but we'll talk about that later on when VimTutor gets to it. So that's how to delete characters. To insert characters you can use I. Now I what we talked about normal mode and insert mode before. Now what I is is basically go into insert mode. So if I go down here and I go right here where there's some missing text or actually I guess there's some missing here and I type I now hypothetically if I type in HJKL it's going to actually type them this is insert mode so I'm gonna delete those. I'm gonna type in the desired text so some and when you're done making your modifications in insert mode adding text you press escape. Now I will say that escape is a little far away from you know everything else it used to be escape keys were actually closer down here so they were easier to touch. I recommend everyone to remap their caps lock to escape that's what I have that's what I use it's much easier some people really remap control now I believe you can also use what is it control L maybe not what is it control someone will say in the comments what it is it's control oh control left bracket that's what it is right so if you don't want to reach up to escape and you don't want to remap anything you can also use control L but what escape and control L and all these keys do is leave insert mode back to normal mode so let's go here we'll type in the missing characters we type in I then type in the characters then we'll press escape and now we're back in normal mode and we can HJKL to move around so I'm gonna put in all this stuff here just for completeness sake so now you've learned how to insert text so another way to insert so 1.5 is appending so insert mode now you don't often want to have to move over exactly where you want to insert stuff and then press I and you know it's a little anal to have to move around so Vim has a lot of shortcuts from moving for moving to key locations and going into insert mode so if I'm in normal mode and I go to this line it says that you can press capital A and this will do two things it'll put you at the very end of the line the line and put you in insert mode so I can press capital A and I can type in what's missing from this line same thing here and notice I press escape once I was done with that so I'm gonna go here capital A missing here and then escape when I'm done so I is insert mode and capital A is a pin to the end of a line now they don't tell you this but there are really I think four main ways to enter insert mode and all of them sort of make sense together now there's using I and using A now notice this I'm gonna go to F right now let's go to R right here now if I type in I I'm in insert mode and I can type in some characters and notice all of these characters get added before R so I'm gonna undo those with you we'll talk about that later but so notice again if I am on a character press I it's gonna insert stuff before that character so one of the problems with that that you might be confused with if you're a beginning vim user is if you're at the beginning the end of a line and you press I it's actually gonna insert text before that period or before the last character now there are really four characters as I said in VIM that put you in insert mode there's lowercase I there's lowercase a there's capital I and capital A so lowercase I puts you so that you can write stuff before the character you're over capital or lower case a which vim tutor doesn't mention puts you in insert mode so you can type stuff after that character you're over so again if I'm over R and I press a now I'm typing after that R now a capital a is a more extreme variant of lowercase a because it instead of going to the right of the character you're over it goes to the very far rightist edge of that line and lets you insert on the other hand you can use capital I and if you type in capital I it goes to the beginning of a line and puts you in insert mode so that's so those are the four different ways I think that vim has of actually inserted going into insert mode and you should really be able to use them pretty flexibly most of the time in actual real-world text editing you're using capital A or capital I or a change command which we'll talk about later I don't actually use lowercase I or lowercase a that often but if you're a beginning vim user you'll probably be using them a good bit anyway so that's appending that's inserting text and stuff like that now editing a file so I talked about earlier or vim tutor talked about Q for quitting again so we'll press Q and it'll actually say oh you didn't write you didn't save your changes you have to press exclamation point if you want to leave so Q exclamation point will leave of them I'm going to get rid of that though now if you want to save your changes and quit at the same time you can type in key colon and then W then Q now W stands for right and Q stands for quit now you can also just type in W alone and that is save so colon W that is save so colon WQ is save and quit and I'll say in addition to this in addition to colon WQ you can just type colon X that just means save and quit if you don't want to deal with that now I mentioned before that my preferred way of exiting vim is actually capital Z capital Q and that will quit without saving any kind of changes now if you want to save your changes and quit extra quick instead of capital Z capital Q you can just type capital Z capital Z very easy that just leaves automatically it saves your changes and leaves so that's basically all you need to know about that so again that's saving editing files you know now you now know how to save and I think I'm gonna stop my video for the time being I'll probably have a part two to this just because we've been going on for a little bit so we've done pretty much all of lesson one so you can see that we are now at lesson one summary a play around with these commands before or again again just to remind you the stuff that we talked about aside from VimTutor is in addition to lowercase I and capital A there's also capital I and lowercase a which you go into insert modes and you know to exit Vim you of course have capital Z capital Z and capital Z capital Q which I use a lot and of course control you control D to go up and down and MLH to move to the high middle low wherever you want to be and ZZ which you know sort of centers you on the line you're on so anyway I'm a little tired of talking I'm gonna get some water and probably do part two so I'll see you guys next time