 Hey guys, one of the most important skills that you need to have when working on a Linux system is how to make use of a text editor And we have a text editor in the form of VIM. It's really powerful and it can be quite tricky and intimidating at first So first up I'm gonna type in VIM at its own and you may notice that there are no menus over here So if you're trying to think that I can click on file over here. Nope, that's not the menu for VIM You see when you make use of VIM it operates in different modes The mode that we are looking at right now is called command mode and this is the default mode Now when you're on command mode, this is when you can make use of special VIM commands And I'll teach you a little bit about that in a moment Now if you want to do edit a file you want to do in edit text you need to be inside insert mode So to change into insert mode you would use I on the keyboard now look at the bottom left hand corner It doesn't say anything about me being in insert mode right now So I'm gonna go ahead and hit I and you'll see right now. I am indeed in insert mode So let's go and type in some text say hello world and there we go. That's my text now I want to save it now We're in insert mode and we need to change modes right now in order to save the file So to get out of insert mode we hit escape on the keyboard and you can see at the bottom left hand corner It doesn't say anything about me being in insert mode anymore Now at this stage, I need to go and change modes one more time I'm inside command mode and I need to go into extended command mode to change into extended command mode I'm gonna use a colon. So again, have a look at the bottom left corner and At this stage, I'm gonna give it an extended command and the command is right because this file doesn't yet have a name So now we need to go and give it a name and it's gonna be called foo So I'm writing foo and I'm referring to a to a relative path So I'm writing foo to my current directory and at the bottom left hand corner You can see foo. It's a new file and it has been written right now Now the next important skill that you need to be mindful of Inside of Vim is how to get out of Vim right now. So you've made your change. You've edited a file and You need to exit right now. So the command is really easy You would use colon to go into extended command mode and you would make use of the command quit Very often these commands may be abbreviated. So let's can try that one more time So if you look inside the current directory, I've got a file called foo And if you wanted to edit foo directly, what you could do is use Vim Space foo. So Vim is the command foo is the argument And you can see right now that I've got my text hello world that I've previously saved Now the command mode is very powerful because what I could do is that I can make use of certain Vim specific commands. For example, I could say why why which is to yank a line or to copy a line I could then make use of p to paste it Now it's not a literal p. I'm not putting p into the document. I'm simply pasting a word now I can also say something like 10 p and I could paste the line 10 times in command mode What I could do is I could go and how about this I could go and delete a word So I'm just gonna go and delete the word world So I'm putting my cursor over the w in world and I could say dw and you can see that I've deleted a word I could move my cursor over to any character and hit X to delete it So again, these are not literal X's and they are they are interpreted as Vim specific commands So so far I've spoken about how to copy and paste files but or how to copy and paste lines But how do you go about deleting lines? So I could say dd to delete a line Let's go and dd one more and similarly to pasting a line multiple times What I could now do is that I could delete n number of lines So let's go and delete the next nine lines And you can see right now nice and simple those lines have been deleted And I only now have two iterations of of hello world Now again if I wanted to go back into insert mode to inject text I could hit I on the keyboard Now what would happen at this stage is that it would take me into insert mode But now I would be editing text on the same line where my cursor is And that's maybe not what I want to do I want to put in a brand new line into this file So what I'm going to do is I'm going to get out of insert mode right now And I'm going to show you the o command the o command will take you into insert mode However, it's going to put your cursor on a blank line on a new line And you can start editing text right away And I can put in a brand new line that says this is rh024 And now again I want to I want to save this file So let's go to hit escape and we are hitting escape to exit out of insert mode And we are now back into command mode And I want to show you something that's really cool I'm now going to save and quit vim without going into extended command mode And how I can do that is by using an uppercase zz So shift zz on my keyboard and there you go It's the same as save and quit And the reason why I was able to do that is because the file already had a name So let's get back into the file foo And we're going to delete that duplicate iteration of hello world So let's go and try that So I've deleted the line and at this stage what I want to do is that I want to quit it So I've realized that I made a mistake I just want to get out of this right now I want to abort editing this file in in all ways And I'm going to say escape colon And we're now going to extended command mode And I'm going to use the abbreviated form of quit Which is q So this stage guys is saying no right since the last change Add a bang or an exclamation mark to override So let's go and try that right now Q yes I'm really sure This is what I want to do And now it quits So guys that is the basic vim workflow Insert mode to manipulate text We have command mode where you can make use of special vim commands Like yy to copy p to paste dd to delete There are many more as well And then I also showed you extended command mode Where we could do things like use the w or the right command to give a file a name We can also make use of quit and abort Without saving any changes And I just want to encourage you that there's so much more to vim It really is a powerful text editor And it's an essential skill that every Linux administrator should have