Vim Training Class 1 - Basic motions and commands

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay so this is the second BIM training class also known as the joy of painting with Bob Ross and by joy painting I mean them and by Bob Ross I mean myself Sean Biddle so there's some things about BIM that are very different than your standard text editor and that is the concept of modality which means vim has modes so instead of just typing text and things appearing on the screen you're in a different mode so the eye key for example won't always put an eye in the file you're editing sometimes it will do something else so if it has a number of modes in the first three that we're going to go over today our insert mode normal mode in command mode and since this is the joy of painting I'm going to use painting metaphors to explain these so insert mode is a bit like having your brush on the canvas you're editing the current painting to create things the next one is normal mode so your brush is off the canvas you may be thinking about what you want to do or you're moving your brush around the canvas without changing it because you don't want to drag your brush across the canvas and paint all over the picture if you just want to move the brush and the next one is command mode this is a lot like mixing your pallet or even creating a new canvas so this is when you want to do things like drastically alter the document in ways that you couldn't do in insert mode or normal mode any questions on those three things before we go on sweet so the first thing is starting vim which you all have done there are two main ways to do that the first is using vim and then just target a file like any other Linux command so you just do them example that whatever or you open them and then you use the edit command which is : E which is short for edit and then you target a file like expert dot one for example but we're going to stay in the beginner mode so those are the two ways to to open vim and then once you actually get into ving you'll notice that it is very different if you start typing things things will not happen the way you expect them to for example if I just try to type my name why didn't the S show up well that's we're about to learn so there are a number of ways to get from opening the document to actually inserting text into the document as you would with a normal arrow and the first one that everyone learns is I which is simply at my cursor enter insert mode for example I'm here I wanted to begin editing so I will hit I and depending on your setup or vim configuration you should see in the bottom left insert appear if you don't we can cover that in the fourth week where we're going over vim configurations so that insert in the bottom left means that you're actually ready to start typing and what you type will be what you think you type so now I can type my name and it's actually my name the next one is very similar but instead of inserting immediately where I am for example if I hit I here it would just start inserting however if I do shift I it will go to the first non whitespace character as you see there if I start typing it goes there this is handy if you're moving around in a file like this and there's something indented very far and you want to edit it but you don't want to move all the way over and edit so you just do shift I and it takes you to the first 911 space character the next one is s now s has a very esoteric usage that will we'll find out how powerful it is later but for now suffice it to say that it deletes the character underneath your cursor and then put you in insert mode like I would so if I hit I here it will put me between the e and the L like so so so so so however if I hit s is going to delete the L and put my cursor in that place like that like so s is the introduction to this concept that you're going to have to throw away any mental map of characters between their shifted and unshifted versions having anything to do with each other so s does one thing which is very innocuous which is just delete the character and the cursor and put me an insert mode s is very much more destructive so if I did s here it deletes the entire line and puts me in insert mode at the beginning of the line this is a very different action so if you're ever editing an editing in them and you hit s unshifted and it deletes the entire line that's an immediate warning that you have caps lock on no I will get to that but not till the end so once you grasp that shifted and unshifted characters can be very different you'll you'll have an easier time and not tear all your hair out so a is very similar to lowercase s except that instead of deleting the character under the cursor and moves to the right of it so you have I which puts me between the E and the M like so so and you have a switch deletes the character under the cursor and puts me an insert mode like so and you have a which puts me between the N and the T and puts me into insert mode like so a is the next one a is really useful but like s it is very different than its unshifted counterpart so shift a all does is put you an insert mode at the end of the line like that this is really useful if you're missing a semicolon for example and you're just going to the file and you're like oh I missed a semicolon there now oh and shift Oh are super useful and they're one of the few shifted and unshifted counterparts that actually share at least some semblance of tangential relativity to each other so if I did oh I'm going to create a new line underneath my cursor and go into insert mode if I do shift o is going to do the same thing but on the line above like so now this is both of them are quite useful if you have something like an if statement I can do if something hit escape then hit O go like that so on or just make my braces and then hit shift out and they'll put me between them there's a lot of uses for Oh we'll get into that next class C has a bit like s a slightly esoteric usage so what it does is wherever my cursor is it's going to delete from there to the end of the line like that a lot of these you won't use very often but the goal of this is to throw them into your head and realize that they're there so when you do come across a situation where they are useful you go oh wait I could have used C instead of doing I and then just holding delete for a long time so any questions about the different keys you use to go into insert mode negatory awesome see as I mentioned here we'll build over next class because that that is possibly the coolest thing about BIM yeah so we're an insert mode a lot there I just showed you how to put your brush to the paper because when you open vim it was off the off the page so now to pick a peg up you just hit escape or ctrl left bracket so if I'm inserting text and I want to get back into normal mode because I just entered insert mode I hit escape or if you don't want to reach all the way over for a scape control left bracket which keeps you on home row and here's the big one so here's why I told everyone to throw their Mouse's out this is because I could do this do not ever do this I could do this you don't want to do this this is bad I don't know where I'm going and just clicking randomly when you have hjkl as you can see here J moves you down K moves you up and H and L move your left and right respectively these are the beginning of the concept of motions which are keys that move you around a file hjkl are the most basic possible but they introduce you to the concept of an argument to command so for example if I wanted to move down two lines I would do - J it's actually moving down three lines I'll explain why later so I'm on the current line I want to move down two lines to line 48 I'll do - J now this doesn't seem like it would be that fast but then you have to realize if I know I'm on line 40 and I wanted to get to line 50 I do 10 J and I'm on line 50 so I so I'm on line 40 I want to get underlined 50 which is 10 lines so I say 10 survey sit if I show you this if you look down on the bottom right you can see 10 J so it's going to execute the J command ten times I'll go into this a bit more later but this is hjkl in addition to being the first emotions are the first introduction into taking the argument of to a command next is why hjkl instead of JKL semicolon because your hands rest on JK Alden semicolon well I'll get into that in the next class because that's some vim trivia that would be nifty to learn so they embedded the mouse why are you not supposed to use the mouse don't just don't while you're learning the mouse is your enemy your mortal enemy you will in fact not live through using your mouse it will blow up so we've covered a lot in twenty minutes so are there any questions about these very large set of commands that I've introduced you to so we have how to get into insert mode how'd you get out of insert mode and how to move around any questions on the other correct because that is the that is the mode you are in when you first open them so already with this set of commands you're already more powerful than notepad or notepad plus plus because you have power over what you're doing even before your pen hits the page for example if I'm editing and I want to delete the entire line I could if I'm in notepad plus plus take my mouse drag all the line I can then hit backspace do some stuff maybe I didn't select the right number of characters maybe I did but in them it's one character and that's exactly what I wanted to do I knew I wanted to do that and I know the command to do the show this is what makes them more powerful than another editor and will will see better examples of this as we go as we go on so now hjk now are the most basic motions you can possibly do the slightly less basic are W B and E and each have an uppercase counterpart and each do something slightly different now if I'm on this sentence here if I want to move to the word beginning I can hit L until I get to the word beginning and I can hit H to go backwards but we have W which is the word motion which takes you forward to the beginning of the next word so if I did w w w it'll move me between words and likewise with hjkl if i do 3 w it will take me three words ahead so if i do three w it takes me two beginning so I'm on forward I want to move three words over this is the first word this is the second word there's the third word so I do three W and move me to beginning now shift W is the first introduction of the difference between a word and a quote unquote word which is this upper case variant that you're going to see a lot in the vim documentation and the difference between a word book a word and a word is the following a word as defined by lowercase W is separated by anything that's not a character so if I had this is a string and did W it's going to move me between things that aren't words but if I did this here so if I do w here it's going to move me between the commas and the words themselves a shift W is a word as defined by characters separated by whitespace so this is a lowercase word this is character separated by none by non characters a capital word is words separated by white space so if I do shift W instead of W it takes me to the next thing that is separated by white space obviously if I do W here and I want to get the string this is annoying if I want to get the string from here and I do ship W takes me right to it next is B which is the same thing as W but backwards so for example I'm on B on the word beginning and I want to go backwards if I hit B once it's going to be take me to the first character up next and so on and so on and so on now if B is exactly the same if I have this sentence here this sentence here and I'm on here I'm going to do shift B it's going to take me there I do lowercase B it's going to take me there so that that's a fundamental thing that you sort of have to keep in your head we get in the fourth class we'll go over how to configure what defines a lowercase word and what defines an uppercase word the next one is e which is the I word this very carefully so it's forward to the next end of word not forward to the end of the next word and this is why if I'm in the middle of the word forward and I hit E it's going to take me to the end of the word forward not to the O so that that might get confusing so if I wanted to get to the end of the word beginning you would think it would be 3e but instead is for E because the D is in between and that is also an end of word shift e is that is the same thing so any questions on WBE before I move on yes number almost everyone almost everyone so like hjkl you can prefix w with for example three w or four e and then that'll do the same thing anything else right so the hjkl and w b and e were the first introduction to having a number before the command now F and T are going to be the introduction of the full syntax that we're going to go over in depth in the next class so if anyone is familiar with back and smell or form it sort of looks like this so you anything in square brackets stuff is optional anything in angle brackets stuff is required so f for example moves me forward until the end oh so we have number which prefixes the verb f in this case and then we have a noun which is the argument to the verb so for example if I wanted to move to the first E and I'm on the a I would do F E right if I want to move to the second e I would do to F II so there are there are in fact two arguments to this one verb the first prefix is the verb which is the number of times you want to execute the command and the noun is the suffix to the verb which is your actual target so you have a count a verb and a noun and this is critical to understanding how VIMS commands work so firstly as i've said f moves you forward until the end o so Fe 2 Fe 3 Fe etc now unlike W and B which are two keys that move you forward and backward F and shift F are the same key that movie for the backward so if I'm here and I move to the previous II I do capital F II now move me backwards likewise if I do to Fe or 3fe other to Fe for example to shift F II it'll move me backwards to the second II so this is really helpful if you're something like you're on this line and you want to go into the set of parentheses that has the word inclusive in it so you know it's the third left parenthesis so you go three F left parenthesis and then you move to that parenthesis now you could do wwwww until you get there but that is not the most efficient movement and vim is all about efficient movements so as noted here in the parentheses F is inclusive which means as we can see here my cursor is on B if I did F G to get to the first G you'll notice my cursor is on G t is the same as f but it's exclusive meaning until that character so FG will put my cursor on the g TG will put my cursor before the G so if you want to think of it as a mamaan ik you have ford until or you have Ford to and then Ford until so we have Ford to and then you have Ford unto or until with G with T so any questions on those two or the generic count verb noun syntax mm-hmm so in the different dreamers but yeah so the difference between inclusive inclusive and exclusive just to recap is F will move my cursor onto the character F G will put my cursor on g TG is exclusive which does not include which which is to say excludes the character I'm searching for civil duty G will move me until that G but not including that G anything else okay so we've still covered a lot of ground so hopefully your brains aren't dead yet and then this brings us to some of the most powerful features of vim which are searching so now almost every text editor has searching but almost all of them have like some weird key combination like ctrl a for a ctrl R and then you have to click a checkbox to select if you want to search for word in the document or backward in the document or something like that all you have to do in vim is while you're in normal mode hit forward slash and you'll get your cursor will move down to the bottom of the screen you will see a forward slash and a blinking cursor now this is where you type the thing you want to search for now for example I just want to search for the word for word I can just start typing f o r w and it's going to go from the top of the document to the next instance of the word for word and to move between them you do N and shift n and will move you to the next result of your search shift n will move you backward to the previous result so for example if I hit n it'll take me to the next word for word and so on and so on and so on and so on and so on etc now if I do shift n it's going to move me backward like so now if you just want to search backward from the start you would use a question mark now I don't really recommend this because N and shift n in this case flip and that's that's kind of hard to keep in your head I did slash forward but not forward forward it's going to look for that and I do n if I instead did a question mark forward and then hit n it's going to move me backwards which is kind of counterintuitive I mean it makes sense but the reason I don't recommend it is because it's kind of hard to keep in your head because you'll hit n and then you'll go in the opposite direction you expect so really I recommend forward slash for most of your searching and there's a setting I will show you in week four that will show you that will wrap around for example I have this set in my configuration so if I did forward and then just keep hitting n until I get to the last one you'll notice that a little wrap back around to the top so I go to line 85 and then it'll gently back down to 64 this is not on by default so by default if you keep hitting n you'll get to the last result you'll stop but as I said in week four I'll show you how to make this wraparound there's actually a command called no highlight which is short for no HL is that right there but yeah it does get kind of annoying so I guess I can as sort of a moving ahead in getting ahead of myself that's how you cancel the highlight so if I did forward I have mine so it doesn't highlight but yours I think by default it does highlight so if you just want to turn it off it's just no HL so those that's those two and I'll get into more details next week but search supports full regular expressions but I don't want to get into that now because there's a whole other argument or a whole other subject inside of in regular expressions to get into so we have forward and backward then we have star which is actually ranked on VIMS website as the most world-changing key in all of them when people find out about it and that is your editing you're in normal mode and you want to search for example the variable that you're on right now so if you just hit star it's going to search for that and then you can then you can hit n and ship tend to move you between those results just as if you did Ford like that what's that right and then G Star is the same thing but unbounded and I'm going to skip over that for a second until I go over a pound so pound is the same thing as star but backward so just like we have forward slash and question mark we have star and pound so that'll take me forward and then pound will take me backward like so and I've already gone over and and ship them so now there's this concept of bounded and unbounded and this is very much if you're familiar with regular expressions as word boundaries so now if I have the word Ford I just do four right and I want to search for the word for and I do a star it's only going to look for the word in its entirety for this is a bounded search now in contrary if I just wanted to search for the three characters fo are and didn't care if it was the entire word or not I'll do G star which is an unbounded search and you'll notice that it found fo our and it was part of another word and this will continue on notice here it found it in between or in the center of another word so that is the difference between bounded and unbounded and the differentiation is incredibly powerful for example if you have a variable that if you have some test variable and you have another variable Gold test and then you just want to search for test there's only two occurrences but if I do G star it'll find that one and then we'll find this one as well so and yes there's a reason why that does that but it is that the reason why that does that is actually super complicated and I'm gonna cover that next week because it is a really really useful feature yeah so for now to move between them out you recommend and in ship ten because just because they're they're more efficient methods to do so yes yeah yes uh I believe I actually that might be a setting I forget actually I have help files right here because this is super awesome health star let's see if we can find yeah there's ignore case which is just a setting that you would set so you do something like set ignore case then you would search for it and then it would be case insensitive but as you notice I would search for the word for word and also picked up capital F for word personally I don't like this because if you're familiar with Linux or UNIX environments are all case sensitivity matters all the time so I don't like 99.9% of the time searching case insensitively yeah however with forward slash there's a much easier way to do that so if you're doing forward slash and you want to search for the word for word you can search that here but it'll only find lower case F if I want to search oh I have said ignore case or case turn that off search for Ford it's only going to find lower case Ford if you want to do it just for this current source you do slash C and that says case insensitive Lee and you can just type forward here that will find it case insensibly there are other switches which draw eyes besides backslash c but i'll cover that next week any other questions about searching sweet so now is copy and paste and I'm going to add another one here which is undoing your changes you undo stuff right and right so firstly is yank and paste now this is one of the first commands that we've run into that is a verb that accepts a noun that is not a single character now yank accepts a noun but that noun is a motion for example instead of doing of YW yanking the character W it will yank the word so if I did YW here and then hit P it will paste the word example likewise if I did let's say - YW it'll copy two words which is in this case just the colon but if you remember I think that'll work as well yeah yeah it might make more sense it's just generally you want to keep the the count verb noun syntax pretty similar but if you remember there's shift W so if I wanted to copy all the way to here I can do to Y shift W and then I've pasted that block and then so the difference between P and shift P is if I do P here I pasted it after the if I do P here I faced it before E right now I think this is a bit more advanced than I care to get into but I'll add this one which is visual selection so if you hit V this actually introduces a new mode and you'll notice in the bottom left that it says visual now if I move around in this mode you'll notice that it's highlighting things drawer there's a lot of stuff you can do in this mode but for now we'll just go over yank so here if I do a visual selection here and then hit Y it's going to yank everything in my visual selection this is a lot like using your mouse to select text so I just do there then P notice that's when it pasted it so any questions about why in p YW you do it - why lowercase W yeah that'll do I wasn't gonna I wasn't getting one word well you'll get the colon included okay yeah so this goes back to the concept of a word yeah a word versus a word so if I did to Y chef W I get that because that's separated by space if I dude - why W I only get the colon because the colon itself is actually another lowercase word right right so if I be you'll notice on the bottom left it will say visual and then you can do any motion you want and they'll move you around a little highlight things now this is sort of the the quick and dirty way to select some arbitrary text like it would be very hard for me if I wanted to select from here to here without using visual selection or my mouse so this is this is the way to select across arbitrary lengths of text so if I did Y here and then pasted it here you notice it looks kind of weird because I pasted on here so let's make a new line and that's what I pasted it also has to use yes yes so any questions about those those four keys they are very more complex than what I'm presenting right now but I will get into that next class because they are super powerful and some of the most powerful keys that you'll use yes yes you can also do yank yank YY and I will copy the line yes so if you did what right so there is a way to actually yank the word while you're in the middle of it but I'm not going to tell you the next week so how as you mentioned if you simply do YY that will yank the line you're on so if I do y y MP you always copy the line if I you'll notice if I keep hitting P you'll just keep pasting the thing that I copied yes if you yes so why is is just like all the other commands so it'll copy it'll take a number argument so if I do - why why it'll copy three lines as I mentioned earlier if I want to move two lines down I do two J which will actually move me three lines so I moved three lines in this right so if I do - why why it's going to copy three lines of a douche if P oh well actually it to you while I Oh so why why when you do - why why actually takes the current line into account unlike every other command in vim so be careful with that so if I do three YY and then paste it here it'll take copy three lines alternatively you could do B select the three lines move to the end of the line or end of the yeah the end of line copy those and then 50 as well yes so any questions on that what do you mean don't get what life it doesn't pick up these well it's it companies think of YY as its own command separate from Y and it takes its own number of arguments yeah so that's actually a really good point so if you think of YY as its own standalone command which is completely disparate of Y you get you get in the correct mindset because there's a large number of scenarios rules you'll see something like star and G star or J and GJ now this is a better example because J & GJ do unbelievably different things even though they have the same letters in them so it's it's hard to wrap your head around it but you have to throw away the idea that letters are related to each other and just sort of have to keep a lot of space in your brain for what each letter does you'll eventually forget where your car keys are but you'll be faster in your editor G doesn't really do anything by itself it's kind of we ran of well you can think of it as we ran out of keys on the keyboard so we're going to do things that's not the real reasoning but it's it's just helpful to think of it that way because I mean you can't really you can't really shift star and get anything meaningful because it's already shifted right I'm going to get in the next week but both both so if you want to select all I I have some extra time which is the only reason I'm going to cover this so I'm going to introduce you to two motions so we're familiar with W B and E right there is another one which is GG lower case G lower case G and that will take you to the top of the file it'll take you to the zeroth character of the file it's it's complement is shift G once and it will take you to the end of the file okay so now we have this set of keys to take us to the top of the file and the end of the file and we know how to select things visually so anyone to want to take a wild guess how you would do the equivalent of a ctrl a and VIN no closed I think about your entry point when you start the selection no not yet correct so gg well you had them flight back to G had d GG ships yeah there you go so you do ggb shift G that selects the entire file now there's there's actually there's visual mode there's two other modes that have the word visual in them that I'm going to go over next week which answers my questions Mike's question about can you select multiple lines at a time and the most powerful in my opinion is is block selection and a lot of people don't even know what that would mean yes no you can copy columns and it's it's a very strange thing when you go into that mode but I'll show you something of what you can do with it I won't show you how to do it if you can see my keyboard you'll you might be able to get the glimpse of what I'm doing I'll do this or alternatively so that that's the concept of block selection so yes so that's actually that's such a great question because it shows off the emergent property of them so if I did this array right index is zero and I want to change all the X's in my line that's that's it's a bit more complicated but I will I will show you how to do it so if I had 1 2 3 4 5 6 and I'm in screen so this might get a little bit weird yeah I'm not sure yeah screen is I think consuming the character oh yeah I but there is a way to increment a number like that but and there there are ways to increment those as a whole but I think screen is consuming my my characters right so this just sort of a glimpse into the emergent properties of them so we learn Gigi right we learned shift G and they seem relatively banal relatively innocuous commands but when you combine that with something like v you suddenly get a very powerful function which is select everything on the page right so Gigi the ship team and this is something that you just cannot get in another editor which is an emergent system like the great point that Graham brought up is if I was inserting text that I did Sean could I for some crazy reason actually pass a number argument to I like if I did three I and type Sean then exit insert mode would it type my name three times why yes it would so once you realize that everything you do in vim for the most part follows this count noun or verb non-relationship you unlock a wealth of potential while you're editing which is bring me brings me to the first class where and I said 90% of their time you're not a programmer you're an editor that edits programs so most of the time when you're working you're not doing you might be doing this so you open a file and then there's a bunch of code that you're scrolling through right very infrequently are you in insert mode the entire time writing entire class's doing stuff and never leaving you never have your pen on the page the entire time if you're if you're writing a book you're going to take your pen off the page at some point because you want to think about what you're looking at you want to add context to your editing that's why vim is so much more efficient with even a simple command like W versus holding the right arrow key or the left arrow key or holding down for example so now we've gone to the end of the the second class wherein I give you your homework okay for for ya questions questions before homework the keys WB yes sir want to just chase you to the end of it yes those are basic enough that I can I can sort of show you those ones let me undo all the changes I've done here so I'll add these to the basic motions so WWE fund them nope so there is zero which takes you to the zeroth character of a line so if I did giro here or take me to the very beginning of the line move to the zeroth character of the line and then if you're familiar with regular expressions you'll you'll notice this as the dollar sign anchor which will move you through the last character of the one so if I was here and I just did dollar sign it's gonna move into last character the line now there's a third one which anyone remember what shift I does differently than I correct so zero will take me to the zeroth character which is to say the very beginning of the line carrot will take me to the first non blank character of the line so if I did zero I move there if I did carrot and move there right so you have a set of motion zero zero interesting yeah that might be a setting but we can even go that and what you did yeah so everyone ready for homework any more questions about anything I've gone over two so far okay now I want you to close this file if you have changes I'll show you how to close it if you do Q you might get an error so if you do Q bang that'll get out of the file well W Q will also write actually I'm surprised that Y didn't go over that is beyond me so I'll go over that first so I'm going to start a new a new instance of in this is some stuff so the way you save a file is with : W right but I'm in a new file so it's going to give me an error because it didn't have a file name I'm going to : W file name so this is a good intro to the command mode so any to if you're an in in insert mode so we have the three modes we have insert normal and command when I first opened vim I'm in normal mode if I want to go into command mode from normal mode so let's set it a sort of matrix about it go from insert to normal I simply hit escape or control LUP LUP bracket right if I want to go from insert to command mode let's go in here then I just hit escape first so I would do the insert to normal right and then : so that will take you to command mode so I'm in normal mode I just hit : I'm in command mode your cursor work much like with the search will jump to the bottom left of the screen then you'll be able to type stuff the first command will will learn is w which just writes the file and then let's go with the other ones so we have normal to command mode and that is just : right and we have normal to insert mode which is that big long list of I shift is shift s see shift C Oh shift o etc and then if you're in command mode and you want to go in it to normal mode you just hit enter so for example I'm in normal mode I go into command mode I just hit enter them back in normal mode simple as that so W to save the file Q to quit the file and you can combine these operations by doing WQ which is going to write and quit the file now as I mentioned earlier if you don't have a file name you'll get a big warning saying that you can't save a file with no name likewise if you've edited the file and then you try to quit van with Shift Q it's going to give you an error saying that you have you have no right since last change no save since you lost change if you really want to quit as the error suggests you add a bang to override so if I really wanted to quit the file I could do this that would throw away any changes I have and just quit the file however I want to see the changes so I'm going to do WQ that's going to write and exit out of them so any questions about command mode insert mode normal mode writing the file recording the phone I'm really surprised I forgot to put that in the beginner document I will amend that document at the at the end of this so are you guys ready for your homework okay so possibly you've edited your VMRC possibly you don't know what your VAR c is so your VAR c is the configuration file that holds all of your settings in vim so the location of this file is home / VAR c this file may or may not exist if it doesn't simply open it I'm going to have a lot of stuff in it and I want you to put these lines in it okay everyone ready right that be in the G then like in the actual for G vim is slightly different you're going to do this while you're inside vim do in normal mode you're going to go to command road with : I'm going to do e right and then you're going to do home then hit tab that will expand to like my documents whatever it is okay alternatively I'm gonna if you use your mouse I'm gonna let you use your mouse because you're in GM if you go to the tool bar and you go to edit there'll be a selection in there that says edit my startup settings if you open that that'll open up your VMRC okay you see that in there okay so this is your homework I'm not going to let you use the arrow keys they will so in normal mode they will no longer do anything so once you write written this I'm going to give you four more to to write and it's essentially the same except that it's I know and then the same commands so that function yeah just better just add some new lugs to the bottom of flour right so so I want your homework is to have these four lines or these eight lines sorry in your MRC so what this means is I'm in normal mode right now my arrow keys won't do anything they'll simply not work likewise if I go into insert mode they won't work either so a lot of people when they go in they they start learning vim they're editing some stuff and normal in insert mode so I'm doing some stuff is awesome I'm going to go down here and more stuff they'll still be an insert mode they'll try to use their arrow keys to move around which is a big no-no insert mode is for inserting text it's not for moving around in the document so the correct way to do it is to exit insert mode and then move around you don't move around the flow of a painting with your brush stuck to the canvas that's just the wrong way to do it yes you could also add right that's going to come up in week four so week four is going to explain this is week two is going to explain everything I have a knife MRC while I have a bunch of stuff that looks like this it's going to cover how to completely customize how to edit your VAR see how to make your own functions how to do your own mappings yes and if we have time it'll possibly go over creating your own color scheme because people like having their own color schemes up most people I know that edit and vim have if not created their entire own color scheme have at least edited someone else's so we'll cover that briefly so that's it does anyone have any questions just getting it down left right yes so I'll show you here got them start up methods no no ignore that that is that is that is week threes homework assignment so you just want this right now yeah so you have no down knop which is no operation and then I know so what this is saying is remap in normal mode down left up and right and in insert mode remap down left up right yeah did you over closing open up yeah Snyder's got tenure coming Oh so any other questions before we conclude this first class yeah visuals you can actually find these this file in particular is going to look different it's going to look like this but you'll be able to find it at this URL it should be : / github comm slash from su plus slash dot files so that has all of my BIM configs I would appreciate it if you didn't peek at them so far because and certainly don't use my vim RC yet because it will completely destroy your vim I would suggest instead you go to this website you go to white fluent comm so I should vivify go to this website and then that will let you preview a bunch of vim color schemes and download the file appropriately and then you can go to either vim gorg and will it'll show you how to install that but yeah that's that same just do I have to restart something like the next time I hope right now the next time you open it up it will have those settings there is a way to do it without restarting them but week 3 everything is next week or week 3 so the homework is to just get using the using them in general yeah using the yeah a week a week will be the first two days will be monstrously frustrating you will hate me with the passion of a thousand suns because most people when they're editing in notepad plus plus or Eclipse or any other editor that's not vim through editing and there you start getting up and left and right because they're not modal editors and they'll Dale you'll hit up and down the left and right so many times in insert mode that you'll you'll you'll probably break your keyboard because you'll get so angry because you're just like goddammit escape and then you'll go into normal mode and you're like son of a it's still not mapped then you're gonna go hjkl I mean like oh look at that my my keep my hands are still on home row like they're supposed to be and then you'll get into this concept of your hands never leaving home row they won't leave from moving around they when we leave for selecting text because you don't mean your mouse anymore they won't leave for saving they won't meet leave for opening your keyboard is your friend and moving as little as possible being is lazy and efficient as possible is the heart of editing in vim so I I think without any further questions I think we're pretty much done with week one all right I'm gonna stop recording now
Info
Channel: Shawn Biddle
Views: 240,646
Rating: 4.9332666 out of 5
Keywords: vim, tutorial, motions, basic
Id: Nim4_f5QUxA
Channel Id: undefined
Length: 58min 15sec (3495 seconds)
Published: Thu Aug 09 2012
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.