 okay i'm going to go through all of the basics of vim so open your editor and follow along to open a file from the command line type the following vim then some files so i have a file called file.txt i'm going to open that one now you may realize that you can't type anything so hit i to go into insert mode type some text now once you're finished you're going to exit insert mode by hitting escape to save this file hit colon w hit enter and to quit vim hit colon q sometimes vim prevents you from exiting if your file is unsaved so if you want to force exiting a file type something like this so to force an exit to q and then this and then hit enter if you want to see the version of vim you're using uh hit colon and then version and you'll see that well on my system i'm using vm9 so far everything you learn should make vim as useful as microsoft notepad the real power of vim comes from what you're about to see in vim you can get the output of commands for example i'm using linux and i have a command that gives me the current date to get the output of this command what i can do is i can type r and then date this is really useful if you need to insert a date really quickly into your file you can actually paste the contents of a file with this r and then i have a file on this directory called script.sh so if i hit enter as you can see the contents of that file got basically included into this file so far we've used three modes we used normal mode which is the mode that you start in we used insert mode which is the mode in which you enter text and finally we use command mode which is the mode that you exit commands from so the basic movement keys are j moves you down by one line k moves you up one line l moves you to the right by one character and then h which moves you to the left by one character keep in mind i'm currently in normal mode if you're in insert mode switch to normal mode by clicking the escape key okay nothing we can do is we can move forward by one word so hit w w w w w as you can see i'm just moving forward by one word every time i hit w i can go back by one word b b uh click b so basically every time i click b i go back one word uh what a word is in vim is hard to define so i'll let you look that up so all of these can be actually combined with numbers so if you want to go down by let's say three lines we can say three j and we move but down by three lines we can move up by three lines so three k uh we can move over by let's say three characters we can say three l uh three h and as you can see we're moving left and right by three characters we can move forward by three words we say three w three w we can move backwards by three words so three b three b uh we can move to the end of a line by typing shift four we can go to the beginning of a line by typing zero we can go to the beginning of a file by typing gg we can go to the end of a file by typing capital g we can copy a line with y so let's say i want to copy this line uh you type y y and then to paste this i type p and as you can see that got pasted we can paste three lines so we can say three g and that paste three times uh we can copy multiple lines so for example we can say i want to copy the following four lines so i'm say four y y and then p actually yeah just one p uh we can delete uh let's say the following eight lines so i can say eight and then dd let's delete this one too and then paste we can delete a single character with x so if i type x just delete one character i can undo with u i can delete three characters so we can say three x that leads three characters uh we can delete a word with dw we can repeat what we just did by typing dot so if i click dot it's going to repeat the previous um command we can let's say delete three words so i'm gonna say d three w we can delete a whole line with dd you can use the dot you can use dot to repeat a previous operation so let's say if i delete this line i can repeat this operation by typing dot dot dot that just leads that just repeats the lead over over so there are different ways of inserting text so the one most familiar to you probably is i you just hit i and that goes into insert mode you can hit capital i that puts you at the beginning let me just show you a little better so if i click shift i that puts me into insert mode at the beginning of a line if i want i can append so for example if i'm at the end of a line and i want to append to this line i can say a that puts me into insert mode but at the very end if i want i can insert let's say below so if i want to insert below this line i can type o this puts me into insert mode below the line i can insert above so for example if i hit uh capital o that puts me into insert mode above the line remember when you're editing you can always undo the operation with you so for example if i want to delete this word and i want to undo this i just click you that undoes the operation i just did typing s will delete the current character and put me into insert mode if i type capital s that's going to delete the whole line and put me into insert mode if you hit r that's going to allow you to replace the character so you can replace you with you if you want you can also enter replace mode with shift r and now when you type something she's gonna overwrite whatever's there with the new text so hello world something like that to exit replace mode just hit escape if you hit capital c that's going to replace everything from the beginning of your cursor to the end of the line so capital c just replaces everything or she's a removes everything from the current cursor position to the end of the line it puts you into insert mode uh let's say you want to find some text so if you want to find let's say hello world you can type colon slash then you can say hello world hit enter and as you can see it shows us all of the matches so to go through your matches you can type n and and and and like this and it's going to basically find or it's going to go to every location where you found a match now to disable this highlighting what you can do is you can say colon and then no h i think this stands for no highlight and that's going to disable highlighting for you you can find a character on the current line so for example if i want to jump to let's say w i would type something like this f and then w it just jumps to w if i want to jump to d i do f and then d if on a jump let's say to e i would do a capital f and then e and that just jumps back to the e for you you can join several lines together so you can do shift j and then just that just joins the line below with the current one now there's another mode called visual mode and this mode basically it acts like the easiest way to explain it would be imagine you highlighting something with your mouse so to enter visual mode just type v and what you can do is you can select some text so i'm just going to select all this text here and what you can do is let's say you can do why they just copies all these files into your buffer and then let's insert paste and as you can see i just copy and paste something the same way you would do with a mouse you can use the tilde key to change the case of your characters so for example you can change this lowercase e to our uppercase e with tilde like this and you can just keep typing tilde if you want you can also do the same with dot so you can keep clicking dot and it's gonna basically change the case of your characters you can do the same with visual mode so for example you can say v select all this stuff go to the end and then simply type fully and now everything is uppercase or i guess everything is uppercase that was lowercase then i guess at the bottom this this line is lowercase because it was uppercase so to lowercase everything here what we can do is we can go into visual mode and then i'm gonna go down to let's say the line line like this select all this and if i hit u that's gonna lowercase everything inversely what we can do is we can go into visual mode we can drop down and what we can do here is we can actually go and uppercase everything like this with capital u and another thing you can do with them is you can substitute words so for example if i want to substitute hello world with welcome world what i can do is i can say s then find hello and then i'm gonna substitute this with welcome as you can see we changed hello to welcome and remember if you wanted disabled highlighting just do colon and oh h hit enter and that disabled highlighting because it kind of gets annoying if it's always on now to repeat the substitution on this line instead of typing it out again what i can do is i can do q then the colon and i can just run this substitution and as you can see you got substituted so again q colon run the substitution again q colon on the substitution you can also do this with real mode so what you can do is type v and then just select everything you want to substitute and then type colon again substitute and then let's say hello and i want to substitute this with welcome i think you have to do global maybe not anyways hit enter and as you can see we just replaced everything with welcome okay so i think that should be enough to get you started vim is extremely complex so don't think you can learn the whole thing in one day or even a month so if you enjoyed this video remember to subscribe to see more videos like this one and i will see you later