This course has been updated! We now recommend you take the Full Stack for Front-End Engineers, v3 course.

Check out a free preview of the full Full Stack for Front End Engineers course:
The "Editing and Saving in Vim" Lesson is part of the full, Full Stack for Front End Engineers course featured in this preview video. Here's what you'd learn in this lesson:

Jem covers editing and saving commands in Vim.

Get Unlimited Access Now

Transcript from the "Editing and Saving in Vim" Lesson

>> Jem Young: So let's go to editing and saving a file in VIM. So we're going to move into last-line mode. So, in VIM, so whatever you have in your file, it doesn't matter if you type some gibberish or anything, press esc, :, so its going to do, its going to be shift-colon on most keyboards.

[00:00:22] Type q, what happens?
>> Jem Young: Hello.
>> Speaker 2: You get an error.
>> Jem Young: Exactly. Got an error. It's cuz VIM says, you can't just quit without saving. Its trying to save you from yourself so you don't actually quit. Its really nice, but if we wanna say no, I know what I'm doing.

[00:00:43] I'm way smarter than you VIM, we can say in last-line mode :q!. The!, means yes I'm serious, essentially. [LAUGH] :q!, plugs you right out of there. So we go back into VI.
>> Jem Young: But let's say we wanna save this file. So w is save. We didn't give it a file name.

[00:01:09] So w, I don't know, testfoo. Save it as testfoo. So I'll do that again. So w, some file name testfoo, that will write and save your file, but you're not gonna quit. So, generally, this is like the muscle-memory I've built in. It's always wq. So, that's write and then quit.

[00:01:37] Shortcuts to having to type your filename in every time is just vi somefilename and that's gonna open VI already saved. So now in inserts, hello, escape, I can just write quit and I don't have to do that weird file name savings, cuz it already has a file name.

[00:02:05] Yes.
>> Speaker 2: Couple questions. Why is VIM faster than other editors? Is it just because we don't have to use the mouse trackpad?
>> Jem Young: Yes, absolutely. High-level context, which is expensive for engineers, you know, when you're working on a project, and your boss comes over and she says, hey you got that thing I sent you, and you like, what I'm doing something.

[00:02:28] Content switching's expensive and the same goes for your hands as well. So if you never have to leave your keyboard you're just so much faster versus this, and that's why VIM is faster. Again, there's probably a well actually person, well actually Emacs is faster, and that's cool too.

[00:02:43] Whatever your best at use that, but VIM, if you're a master, you are just flying across the keyboard, because again, you don't use the mouse at any time. You're just mastering everything.
>> Speaker 2: The other question was, can you map these commands to other inputs, like to handle all the new MacBook Pro won't have the escape key?

>> Jem Young: Absolutely. VIM is infinitely configurable, the first step when you install VIM is probably installing a bunch of plugins, same you'd do with Adam or Sublime, or VS Code, or IntelligeN whatever. Plugins make the world go round, and VIM has a bunch of plugins, and it's totally, totally configurable, and that's also what makes it very, very powerful.

[00:03:23] So we can add syntax editing, or syntax highlighting, file editing, all sorts of other things. Oops, too far. Question. James has a link in the chat room for mapping escape key on the, if you have a brand new Macbook. Which if you have your brand new Macbook, that's awesome, I wanna see it.

[00:03:44] Anybody have one? No, I wanna see that control bar, that's cool.
>> Jem Young: But yeah, again, we're seeing escape key is so powerful. That's why I don't understand why they took it out, because you really need it in VIM. So at this point, does everybody here understand how to write in VIM and save a file?

[00:04:04] Because we will be doing this later and if you don't know I'm gonna laugh at you.
>> Speaker 2: [LAUGH]
>> Jem Young: No, I won't, but we will absolutely need to be able to edit files on a server and there is no GUI to control, paste into, and let's say you really love this, let's say, Jem, you inspired me to become a server administrator.

[00:04:24] So you're in this big, cold building with a whole row of servers, and you just have a terminal to access all these servers. You have to use VIM, cuz you can't copy, paste, you can't do anything like that. It's only a command line. So, again, we're seeing the command line is the ultimate toolbox in every engineer's toolkit.