yego.me
💡 Stop wasting time. Read Youtube instead of watch. Download Chrome Extension

Vi Lesson


3m read
·Nov 3, 2024

Processing might take a few minutes. Refresh later.

Mac heads 101 here. Today this is going to be a short little VI lesson, so let me just explain some background information to you.

VI is a nice little word processor in UNIX which people used to use before nano was available. Nano is sort of cheating because you have arrow keys, but nano doesn't work on old fashioned terminals that don't have arrow keys because the old fashioned terminals didn't have arrow keys. VI does not require any arrow keys.

Now, VI has a system: there are two modes, insert mode and normal mode. Insert mode is when you type a key on the keyboard and it types it; it puts it just there on the screen. Normal mode is when you press a key and it will process the key and the key commands will work. So, I don't understand this right now, so I'll just show you.

VI is just like nano in that you type VI space and then the file name, and if the file name has spaces in it, then you type the file name in quotes. So I'll just make it called "was here." Now I hit enter, and the VI screen will come up. It looks like this; it has these nice blue lines, normally when it's a new file. If it's a new file, it will say the name of the file on that it's a new file.

So right now, we're in normal mode, so we can type a key. Let's press 'a'; it won't work. Now when you're in normal mode, you can press 'i' to go into insert mode, and it'll say insert at the bottom here. Now I'm in insert mode because I just pressed 'i', so now I can type "I was here," and now I'll put a period. I'll hit enter twice and type a new line.

Okay, so now I can type escape to go back to normal mode. When you're in normal mode, like I said, 'i' goes back into insert mode, and then you just start typing where your cursor is. But if there's no arrow keys, how do you move around? Well, it's simple! When you're in normal mode, you press 'k' to go up, 'j' to go down, 'h' to go left, and 'l' to go right.

Now I can move to the beginning of this line with 'h'. I can move to the end of this line with 'l'. I can move to this top line with 'k' and back down to this bottom line with 'j'. I can also do the beginning. Now, say I want to put something after the period here in this line, um, in "I was here." How do I do that? Well, you think it's pretty simple! I press 'l' to move over here to this period, and then the problem is now if I press 'i' on the letter before the period, I can't get past that period to type after that period.

How do I do this? When I'm in normal mode, just like the 'hjkl' keys, you can also type capital 'A' by doing this: you hold shift and 'a'. So in normal mode, it automatically brings you into insert mode, as you can see from down here, and it basically brings you to the character after the last character of the line. Then you can type double-space and say "I am Alex."

Now say I want to write to the end of "hi guys." This one! I just go down to this line in normal mode, press shift 'A', brings me into insert mode, and I can immediately start typing here. Now, I said I want to save this and exit VI at the same time. I press escape to go back into normal mode, so I press the escape, and now I take colon 'x.' Then I hit enter, and now it's exited VI.

Right here on my desktop is this file, which I just dragged over from the side called "I was here," or I called it "was here" because that's what I named it via. So I can open this just to prove that this is real! Here, the file says "I was here! I am out! Hi guys! I'm a hi Dave." You know, I don't even remember writing that in the file or whatever. I'm random. Anyway, so yeah, that's pretty cool.

So I want to save my changes. I can also see "I was here," and go back down and say I don't like this line in between these two other lines. While I'm on this line, I can press 'D' twice really fast. Um, so I press 'DD' and it's deleted that middle line. Say I want to delete this "hi guys! hi Dave." I press 'DD' again, and now it's deleted that.

I'm going to go to the end of this line, make a new line, and type "oh crap." Now I can click escape and then pull an 'X' and it's just saved "a was here." Yeah, pretty cool, huh? So I can also VI it and say I'm editing, and I just want to save without exiting. Heck! Well, I can just press escape, and instead of colon 'x,' I do colon 'w' and...

More Articles

View All
The Side Effects of Vaccines - How High is the Risk?
Vaccines are celebrated for their part in fighting disease. But, a growing group of people seem to believe that they endanger our health, instead of protecting it. The Internet is full of stories about allergic reactions, the onset of disabilities, and ev…
How to sell a corporate jet!
Budget is about $5 million. Looking for a plane to fit seven to eight people. Are you familiar with any of the aircraft models that they might be interested in? One of the partners currently has a plane right now. I’ll get you the specifics on it. I think…
Parallelogram rule for vector addition | Vectors | Precalculus | Khan Academy
[Instructor] So we have two vectors here, vector A and vector B. And what we’re gonna do in this video is think about what it means to add vectors. So, for example, how could we think about what does it mean to take vector A and add to that vector B? And …
Join This Man on a Safari to Sculpt Animals in the Wild | Short Film Showcase
Africa is where I sport up; it’s a place that completely fills me with excitement. I enjoy the heat, the thorns, the smells. To me, it’s all hugely evocative. African wildlife is so diverse; 6:18 is such a movement, such a lot of character. All these thin…
What we've learned in 100 Episodes - Smarter Every Day 100!!
[party whistles] Hey it’s me Destin. Welcome back to Smarter Every Day. A very special Smarter Every Day. The 100th episode, but not only that, it kind of coincided with a million subscribers, so thank you very much for your support. And because of that, …
Climbing Asia’s Forgotten Mountain, Part 2 | Nat Geo Live
Hilaree: So many things went awry everyday. It was a lot of hard work. And to get to base camp when I think of all the times we almost threw in the towel, it was a total relief. Both: Oh, we made it. Climb on. We’re at what… like 11,000 feet we have 7,00…