Transcript from the "VIM Practice" Lesson
>> Jem Young: So let's give it a shot. We're not gonna do too much yet, but memorize or understand how to do these commands like how to type, how to edit, how to save and quit. Because we will be using them pretty much all day. It sounds intimidating. It won't be well, we'll go really slow.
>> Jem Young: So to fire up vim, you can type in vi, the man pages again just to show you that what we're doing. I don't like to give you commands and you don't understand why. So I'll just do it now, clear, and I'll type in vi.
>> Jem Young: Nothing to it.
[00:00:39] Now we're in a text editor. Let's say I wanna type something. So right now I'm in command mode so I can just say i, and at the bottom screen here we see insert, means we're in insert mode. Hello, and to get out of insert mode, hit Escape. And now I'm no longer in insert mode, right?
[00:01:00] We've got this so far. It's intimidating until you start playing around with it. So to get into last line mode, I'm gonna hit Shift+colon. See there's a colon here at the bottom screen. And to quit, I can say q, but it's not gonna let me, thus the Q bang if I wanna override, but I don't quit yet.
[00:01:22] Let's say I want to save this file, as, something, I don't know. So I can say wq, I didn't give it a file name, and I'm not gonna name this one. So I'm just gonna say q quit.
>> Jem Young: Did everybody managed to get in and get out? That's, [LAUGH] probably 90% of it is just getting in inserting something and getting out.
[00:01:42] If I wanna create a filename, actually, I think we'll do it on the next exercise, yeah. So let's create a file. I could say, vi call temp.
>> Jem Young: So now I'm in the new file, I'll say, go into insert mode, say hello, everyone. Exclamation points and to write quit say wq.
[00:02:07] It means write and quit. If I just wanna save I hit write, can't open file for writing, what? wq, try that, I don't know why it's not letting me write. I know why. This we are gonna learn a lesson in permissions. So right now I'm in root directory, so I'm going on a tangent, and you can't write things in root directory, it just won't let you.
[00:02:31] So what I'm gonna do is I'm gonna cd~ and what this means is it's just change directory and this is just shortcut for home. So now if I do pwd, I'm in my home directory, now I can write files freely. Almost, actually not almost, no operating system is gonna let you write in root, in the root directory, just cuz it's a bad idea.
[00:02:56] [LAUGH] You don't wanna mess in here cuz this is the base of your computer and if you start writing files left and right, bad idea. So always we wanna make sure we're just in our home directory or some working directory. And ls, we can see we're in our directory.
[00:03:10] So now, vi temp, and now I can write Hello everyone! And w quits, save, if I wanna take a look at that, I can say cat temp, nothing to it. I can use less temp, Hello everyone! Nothing to see, q to quit. All right, everybody in, out, edited a file, saved it?
[00:03:38] Cool, we'll be doing more of that later. So I don't wanna spend too much time on it. But you will get stuck probably and you're gonna get stuck with bad permissions or something like that. Just let me know if you do or reference back the slides and make sure when you write a file, you're in the right directory with the right permissions.
[00:03:56] So that was vim. I just spent a lot more time on it. But then I realized, you learn by doing not by me telling you.