Easy Improvements: Syntax Highlighting & Line Numbers
00:00 Before, we’ve seen VIM in its bare-bones version, and in this video, I wanted to show you some very easy improvements that you can run on any installation of VIM and that already come with the editor. They’re going to make life much easier and more colorful.
We’ll look at syntax highlighting and line numbers, specifically. Back over here in our little script, you can see at the moment, again, I’m in
INSERT mode, so now is the time when we want to switch to command mode because we actually want to execute a command, instead of typing something into the text here.
Oops, I mistyped here, so let’s do that again.
:syntax on—there you go. And we can see here that now syntax highlighting is switched on. This is already much easier to look at, especially when you’re in a big file.
00:59 Now we can easier read what’s going on. We see that here we have a function that we’re using, those are reserved keywords. You can see here, there’s a variable, and integers are highlighted in red.
And again, obviously you can change a lot of this stuff—it’s very editable—but this is the default syntax highlighting that VIM already comes with and that you can simply switch on using this
:syntax on. Switching it off again also works as expected. You can say
:syntax—gotta type it right—
01:55 then you see on the left side here, we have line numbers popping up, and that can be helpful because VIM gives you a lot of freedom for navigating. You can navigate to a specific line number very quickly.
We’ll look at it a bit later, but yeah, just so you know, there’s these two commands. If you remember these two commands—that is,
:syntax on and
:set number—you can already have a much nicer experience with VIM.
02:38 So here, I will open up a bigger file and just show you how much nicer it looks if we switch on those two features that we just talked about. This is just a Django settings file. You can see how it looks like right now—it’s a long, long file, and everything is just black and white, so it’s a bit difficult to know what’s going on. However, with these two improvements that we just talked about…
:set number, switches on the line numbers, and now we can see all of this going on here. Much easier to navigate. So yeah! Remember there’s two commands and you’ll have a better VIM experience already pretty easily.
Become a Member to join the conversation.