Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Overview & Use Cases - Vim

Learn more about Vim in our dedicated tutorial: VIM and Python – A Match Made in Heaven

00:00 Welcome to the section about VIM. Here, we’re going to talk about the classic Unix text editor, VIM, which comes from Vi IMproved. That’s what VIM stands for, but I don’t really know what VI itself stands for, but whatever it was, VIM is one, but improved. Okay, ha.

00:18 We’re going to start off talking about the overview of how does the text editor VIM work and what are common use cases.

00:27 I mentioned that it’s a text editor that’s built into the command line—in Unix systems, that is, so for macOS and Linux operating systems. And to open up a file in VIM, all I need to do is type in vim and then I can give it a filename—for example, test.py

00:44 and it opens up the VIM editor for me. Now, one very common thing people get confused by is if you start typing here—I’m pressing, let me actually switch on my key commands.

00:55 So, when I type something here, now—you see? Down here at the bottom, you will see my commands. I’m typing, but nothing is happening. So, that’s a very common introduction to VIM for people.

01:06 And the reason is that VIM works in different modes. There’s a command mode and an insert mode for the two most common ones. There’s also other modes, but we’re going to talk about those two.

01:16 So when I press i, I’m switching to insert mode, which means now I can type whatever I want—duh duh duh duh duh. Whoops, ha.

01:25 Okay, so I have to have this window selected, and now when I press i, I switch to insert mode. You can see down here at the bottom, it tells me now I’m in INSERT mode. And now I can type, and I’m actually typing something, so now it’s happening what I would expect it to happen from a normal text editor. If I press Escape, I switch back to the command mode, which you don’t really see any notice down here, but this means that when you’re typing now, nothing goes in there.

01:53 Command mode allows me to do certain commands, so if I press the colon (:) here, I can go and, for example, save the file with a :w, et cetera.

02:02 We’ll talk about these commands a bit more in just a bit. For now, just keep in mind that there’s those different modes—the insert mode and the command mode.

02:09 It’s two modes that you can switch between. Now, this whole thing already sounds pretty complicated, right? So, there’s this question, “Why would you want to use VIM in the first place?” And the quick answer for what are the good use cases is generally that VIM is just there. It’s built into your command line if you’re using a Unix system, and if you’re working with anything on a server, it’s very likely that you’re going to be using a Unix system, because most servers today are using some kind of Linux operating system.

02:38 That means that if you’re remotely SSH-ing into this server, VIM is going to be there for you. So anything that you know about using VIM is going to work there, while other text editors or IDEs, they’re just not going to be there.

02:53 So, the main reason for using VIM is pretty much that it’s just ubiquitous. It’s there. And another advantage for using VIM is also that it’s very lightweight, so everything executes very quickly, and it kind of stays true to this understanding that, like, code is just text, right?

03:10 Text. It’s a text editor in its purest form, so to say. We’re just writing text here. Now, that makes it very lightweight and fast, but it also doesn’t give you a lot of functionality that some of the other text editors and IDEs that we’ll talk about later are providing for you. Okay, so I think that’s the quick overview of what is VIM, or VI.

03:32 How do you get in? You just type vim. Let’s do this again.

03:38 You type vim and then the filename, or just vim and then you have to decide for the filename later on. It opens up. And then, how to get out—which is one of the most Googled questions, supposedly, on Stack Overflow—is you press Escape to go into this command mode, and then you type colon (:) to start a command, and q. :q allows you to go out.

04:00 Now, this is not going to work—ha, okay, it works.

04:04 Um, if I make some changes, this wouldn’t have worked—let’s do this again.

04:08 And the way to get out of this is that you press Escape to enter the command mode.

04:13 Then you type a colon (:) that starts off, “I’m going to type a command now,” and you press q for quit, and that closes the editor. Now, if you would have already typed something in there, there’s some overwrites or you have to save it with a filename—we’ll talk about this a bit. But those are the very basics, and to review, VIM is a very basic, lightweight text editor that’s built into your command line on any Unix operating systems, which means it’s going to be very lightweight, and it’s going to be pretty much everywhere.

04:43 Those would be your reasons for wanting to use it, because if you know how to navigate with it, you can also work on a server with the same text editor that you’re already used to. Okay! So, in the next video, we’re going to create our little code snippet and run it and I’m going to show you how to do this using VIM. See you there!

Avatar image for reblark

reblark on Feb. 28, 2020

VI is a text editor developed by Bill Joy at Cal Berkeley before you were born. :-). Joy later became the tech founder/guru at Sun Microsystems. VI stands for visual interface.

Avatar image for agaspar

agaspar on April 15, 2020

And it was a heck of an improvement on ed (or even ex)…

Avatar image for Mark de Lange

Mark de Lange on April 9, 2023

on windows see notepad.exe :) (Also always there) And if you want to go fancy notepad++ (free download)

Become a Member to join the conversation.