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

The "VIM Exercise" 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 provides some commands to use in case you get lost in the command line and how to switch modes in VIM. Students are then instructed to navigate to the home directory, create a "temp" directory, open a "test" file in VIM, write in the "test" file, and save and exit.


Transcript from the "VIM Exercise" Lesson

>> Hopefully, everybody now is a little bit more comfortable with the command line, making things, deleting things, that's pretty much what we do. We just make things, we execute them, we might change some permissions, we might move some files around, we might copy them, but this is what we do.

And from here, we can build an entire universe, which is just fantastic. I don't know, I love this course, I'm getting excited now. I have a slide here called, In case you get lost. Because chances are you might get stuck doing something, and we wanna make sure you don't get stuck.

So if your second directory is cd .., will move you out of that directory, pretty straightforward. If you're like where am I? pwd, print working directory, will tell you exactly where you are. clear, if you have a whole bunch of log files, something like that, you're like, it's gibberish, clear will clear your terminal.

It doesn't delete the history, it just clears your terminal, so you can always scroll back up. Ctrl+C will exit almost every program. It is possible to get stuck in a loop, but that's pretty uncommon, and we're probably not gonna do that today. It's possible to get stuck so bad that we have to close our terminal because it won't respond to Ctrl+C.

But almost always in node, or bash, or anything we're gonna use today, Ctrl+C will get you out of there. And we talked about cd today, will get you to your home directory. So we learned how to move things around, we learned how to create things, we learned how to navigate our filesystem a little bit.

Let's talk about how to actually edit files themselves within the command line. This is where, for frontend engineers, it gets a little murky, because I love VS Code. VS Code is fantastic, or Sublime, or JetBrains, or Notepad++, okay, I'm out. I'm sure there's more, someone's like, Jim, you forgot about my favorite editor, that's great.

Editors are great, they're powerful, they do so much for us now, especially with autocomplete, and you can run commands in there, you can even run the browser from within your editor. Vim has none of that, well, it has plugins and things like that, but at its core, Vim is really simple.

It says, I just wanna edit a file and I don't wanna go through a lot of trouble to do it. That's a really simplistic view of Vim, and I'll talk about why in a second, question.
>> Just comments, the primate gen was summoned when you said them. We're not gonna go that deep in the Vim, we're gonna go surface level just enough to do what we need to do.

But you can go hours, and hours, and hours in Vim configuration, and getting really good. In the beginning, it's gonna feel weird, you don't use your mouse, you have to use kind of esoteric commands to navigate. By the end of this course, you will see why Vim is one of the fastest ways to code and edit files.

And you're like, I don't know, Jim, I'm pretty good at VS Code, Vim is almost always gonna be faster. There's a reason why you see people flying around, and they're always using Vim or Emacs or something like that. Cuz once you don't have to use your mouse anymore, you now have two hands to do stuff.

We'll jump into that, though, and we'll link to the course on if you really wanna get good at Vim. So Vim is a text editor, I said it's pretty basic, but also said it has three modes, and you're like Jim, are you lying to me on its basic?

Maybe a little, Vim will get as complicated as you want, there is a baseline level of knowledge you have to have to navigate around. But the modes we need to know primarily are the insert mode, so that's when we're actually inserting text into the file, or modifying some way.

You have the primary mode, which is kind of the baseline when you open Vim, that's where you're at. And then you have command mode for searching, saving, actually exiting, etc. So we're gonna touch all these here. The way to get to these modes within Vim are you press i to get an insert mode, ESC to get into normal regular mode, kind of back to the default, and command mode is the colon.

All right, for this exercise, navigate to your home directory, make a directory called temp, open a file called test with vi. So if you want, you can touch test, and then open in vi, or you can vi test, and it will create the file for you. Write a few lines, and then save and exit.

And the way we save and exit is command mode wq.

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