Check out a free preview of the full Full Stack for Front-End Engineers, v3 course

The "VIM Solution" Lesson is part of the full, Full Stack for Front-End Engineers, v3 course featured in this preview video. Here's what you'd learn in this lesson:

Jem walks through the solution to the VIM exercise and provides some resources for more information on VIM.

Preview
Close

Transcript from the "VIM Solution" Lesson

[00:00:00]
>> How is that, everyone? Little uncomfortable, little weird if you haven't used Vim before, like why can't I use my mouse? So let's go and walk through the exercise and I'll tell you why Vim and why we're gonna use Vim today for editing our files and not some of the other solutions.

[00:00:18]
So I'm gonna jump back to my terminal here. Write clear, so the instructions were to navigate to your home directory. I am here, pwd, and I'm gonna make a directory called temp again. So make your temp. Well, maybe I didn't delete it. Last time, okay, and I'm just gonna make it again to temp.

[00:00:50]
All right, on mkdir, if you wanna make an extended, you wanna follow it so if I wanna just tip if you wanna say mkdir -p. So I can say tepm/foo/bar. Read only files, how did I get there? Ls TMP, maybe I do the Rockmount, will look this up, because now I need to know.

[00:01:19]
>> Do a ./ for temp.
>> Let's try the ./. And let's use the arrow key to jump up to my history. Good call, ./. So now when you navigate in the temp, we'll see foo, we'll see bar. So the -p will let you make extended file system down and down and down instead of make a directory.

[00:01:45]
Go into that directory, make another directory. Go into that directory, et cetera. And thanks for the tip on the dot, in this case. So next, we're going to open Vim. So we can say VI, I think we can all say Vim. We'll try them. Yeah, you can say Vim.

[00:02:02]
You can save VI, they both work. So now we are in command mode, so we can't really do anything. If you touch keys, you might get into a weird state like macro mode or things like that. We just say I, so now I'm in insert mode, we can see at the bottom it says insert.

[00:02:18]
And now I'm just gonna say hello, not a whole lot there. That's really groundbreaking programming here. So I need to get out of command or I need to get out of insert mode now. So I'm gonna hit escape and I'm gonna hit Shift Colon. And I say WQ if I wanna write and quit.

[00:02:43]
And now, I can say cat test. Hey, it says hello, that's awesome. So a common way of, this will happen to you at some point, I promise. You will say, I edit this file blah blah blah blah blah. I don't really like that, so you can hit escape U.

[00:03:10]
Once were back into primary mode, say U undo, pretty cool. Now, what if you say, hey, I don't really wanna save this. So the challenge with Vim is if you do something, hello world, and you hit Escape, and you're like, I just wanna quit, so I'm just gonna say Q.

[00:03:35]
It's gonna say, hey, you didn't save your file. So if you say Q, bang, that means do what I say. That means you're forcing it. So I've definitely done that many times where I'm editing a file and I didn't mean to. The undo doesn't work for some reason.

[00:03:53]
And I'm like, what do I do? I don't want to save this. Just to bang. And if you ever get stuck in, and you will, don't worry, Vim feels unnatural. If you get stuck, escape cubing just we talked about. It's a common joke on the Internet, you get stuck in Vim.

[00:04:15]
It's really easy to do cuz people don't know. They're like, just open this file and edit it. They read the tutorial of mine, but they don't really go into more detail about how all that works. There's a course by the Primagen, also a Netflix engineer. It's called Vim fundamentals.

[00:04:33]
And if you can see the length, it's four hours of Vim. Four hours of Vim, so you can go really, really deep. We spent what, ten minutes on it. That's really all we need to know for today, but you can go really deep and come really productive if you want to.

[00:04:47]
Fair warning, the people that I've seen at work use Vim are really efficient. But It takes a long time and dedication to become good at it, cuz it's just not a natural way of programming for most people. But if you do, you will become very efficient at it.

[00:05:02]
There's also links here about Vim. There's an entire wiki dedicated to Vim, if you're wondering how hardcore people get. There's a cheat sheet telling you how to navigate around how to find things very quickly and then Open Vim is a nice set of animated examples and things like that.

[00:05:18]
So again, like we said at top of this course, everything we're doing here has so much more complexity that we're just not gonna touch because we could spend an entire day on most of these topics. We could spend an entire day on shell scripting and things like that, and how to use your terminal.

[00:05:33]
We won't do that today. We're learning just enough to know what we need to do and to get you some familiarity with kind of how all these systems tie together.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now