Check out a free preview of the full Introduction to Bash, VIM & Regex course

The "Introducing Vim" Lesson is part of the full, Introduction to Bash, VIM & Regex course featured in this preview video. Here's what you'd learn in this lesson:

James introduces Vim, an interactive text editor program for Unix that is popular for its rich features and as a development environment. The Vim editor supports ANSI codes that are special instructions that your terminal interprets and renders like moving the cursor around, change colors, or set editing modes.

Preview
Close

Transcript from the "Introducing Vim" Lesson

[00:00:00]
>> James Halliday: Let's start in on the Vim topic. If you're working on UNIX systems, there's kind of no way of getting around Vim or VI. Vim is a kind of new editor, new being, maybe let's see, how old is Vim? So Vim is only 24 years old, it's very new.

[00:00:28]
It's based on an older editor from the 80s called VI. I think the first version was made by Bill Joy, who's one of the people who started Sun Microsystems. Also one of the people who is behind BSD, just kind of Unix. And we're gonna be playing around with Vim.

[00:00:49]
So it's very important when you're starting out to find a cheat sheet. So there's a couple of examples. I'm gonna paste those into the chat. I'll go ahead and open them up
>> James Halliday: And Vim is also like Rajax/g] kind of its own little language. So it might be a bit strange to think of a text editor as being a language, but this let's you be very efficient in kind of making edits to files.

[00:01:25]
And kind of cutting things up to a character and then putting them somewhere else, and you can sort of compose all of these different things you learned in kind of novel ways which I really like. I've been a Vim user for a very long time, and I do this stuff constantly.

[00:01:47]
>> James Halliday: You might have to use Vim [LAUGH] if you need to edit config files and things because pretty much any Unix system you're gonna run into has it already installed. If it doesn't have Vim, then it's gonna have VI which is sort of like a reduced subset of Vim.

[00:02:04]
If your SSH'ed into a server, it's not like you can open up sublime text or whatever graphical editor du jour is popular. Also maybe you're on a constrained environment that couldn't even load that kind of program cuz it just doesn't have enough memory, maybe it's a wireless router or something like that.

[00:02:27]
Although I don't think wireless routers typically have VI, but sometimes they have ED, which is also one of Vim's VI ancestors, but ED is a very [LAUGH] strange editor that you probably won't have to use ever. But the main feature, I think, for using Vim is it's really good for programming and it's really good for being really fast editing files.

[00:03:01]
>> James Halliday: So what makes Vim a good editor for doing computer programming is it has a lot of features like indentation this kinda stuff, syntax highlighting that are really handy for making computer programs. But I think the main reason why I like it is you could just be really fast.

[00:03:22]
You can kind of shred on text files once you get good enough at it. VI isn't the only kind of editor that you can use when you're logged into a remote system, for example over SSH. You can also use things like nano or emex, but I'd say emex is a pretty good editor, but it's a little bit more long-winded than VI.

[00:03:48]
It doesn't quite have all of the terse little shortcuts that you get in VI. Although, of course, emex is extremely configurable, so you can configure it to behave just like VI or Vim, but then at that point, why not just use VI, it's great. [LAUGH] There's also nano which is a lot easier to use, but it's kind of, I would say it's a bit clunky to use.

[00:04:14]
It's not quite as terse at a lot of things, and it can't really do a whole lot, either. But if you're on a system, if you're SSH'ed into something, it's perfectly capable at editing files. And it's very commonly already installed on systems, so it's good to know. It's good to like experiment a little bit with it,

[00:04:38]
>> James Halliday: But we'r e going to be during VI. So VI or Vim is an example of a program that's interactive. So this means that it uses ANSI codes which are special character sequences that do things that control colors. They can also move the cursor around. It can blink even, the text.

[00:05:03]
So here I've got in the notes a little bit of fun things you can try out if you like just to play around. So if you do this echo command, -e means interpret escape sequences. You can do this hexadecimal escape sequence, x1b, and then print stuff out. So I'll just show you really quick what this does.

[00:05:25]
Yeah, so it's kind of cyan colored text. You can do other colors by changing these values, so, whoa, that's neat. That's the background, that's cool. Anyways, sort of what editors like VI and also other interactive programs are doing behind the scenes. More fun stuff and a Wikipedia page that you can play with later if you like.

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