Useful Vim Commands
00:00 Welcome to the fifth video here in the section about VIM. And here, I want to show you some useful VIM commands. Now keep in mind, I’m not a VIM professional myself, and this video is not meant to take you to be VIM professional.
00:12 That’s actually quite a learning curve, and some people who go down that path, they become very quick and very functional using VIM, but I here just want to give you a little peek of what’s possible and show you some useful commands for navigating, as well as basic interactions with your code. So, heading over to this Django settings file, I’m going to stick with this one here because it makes a bit more sense to see it in a bigger file.
You can use the arrows to move around just as you would expect, but there’s quicker ways to get to where you want to be. So, for example, to get to the end of the file, you can just press Shift +
G, the big G. It takes you all the way to the bottom of the file, wherever that is.
And pressing two small g’s—
gg—jumps back up to the beginning of the file. So that’s, for example, two very quick ways of moving around. Or you can jump to the end of the line by pressing the dollar sign (
$), that just brings you all the way to the end, or you can press the zero (
0) to go to the beginning of the file.
I’m just quickly going over to them to show you that there’s all these quick ways of navigating if you know all the keyboard commands. Another way would be, for example, pressing
g and the big
A takes me all the way to the end of the file plus enters insert mode, so now I can start typing here right away.
I can undo this, pressing the
u character, and here it is again. Let’s jump back to the beginning. Okay. And up here, I can copy this line, for example. In VIM that’s called yanking, so it’s a double
02:13 just pressing a simple single key. So, you can see here that that’s where the power of VIM comes in and where people who took the time to actually learn all of these many, many commands that exist—they can excel at this, because you don’t have to move your hands off your keyboard at all and you can do lots and lots of stuff very quickly.
02:33 Let me show you two more things. We’ve switched on these line numbers before, on the side. One thing that’s useful for this is that in command mode I can, for example, go to a specific line by just typing the line number, and it takes me there.
And now I could go to the end of the line and go into insert mode and I could start typing there. Even better if you know a certain place where you want to go to—let’s say I want to go to
DATABASES here, right? But I’m somewhere else in the document. I can search for it in VIM using the
and it takes me to the first time where it finds
templates. Okay, so enough about those commands. I’m sure you’re not going to remember all of these commands that I typed here, and I’m going to tell you that there’s tons and tons more of them that I don’t use very often, and that I probably don’t even know about. So with this, I just want to give you a quick peek into what’s possible with VIM if you become a power user. So if you really want to go into that, it’s all about the keyboard shortcuts.
03:42 So if you enjoy that and you’re good at remembering, then go ahead and make VIM your own, and I promise you people are going to be impressed, ha. All right, that’s it for this video. In the next video, we’re going to talk a little bit more about stuff you can do to get more professional using VIM. See you there!
Become a Member to join the conversation.