How to edit and save text files on the command line with VIM

Description

Collection: Change Management and Version ControlChapter: Installing Git and Working on the Command Line

Transcript

Another place where it's easy to get confused is in a text editor on the command line. Because you don't have any buttons, you don't have a mouse, then everything has to be done with the keyboard and there's not a whole lot of space in the terminal window to show you any help. So for example, in the last video when we were talking about why it's okay to be a little scared of the command line, we went through an example where we modified a previous commit message.

Let's go ahead and modify it back to be what it originally was. So I'm going to go ahead and type in git commit and then I'm going to pass it the amend parameter. When I hit enter, this opens up vi which is a text editor on the command line.

Now, depending on what operating system you use, this could also be vim, V-I-M, or nano, N-A-N-O, or if you're following along on Windows, this may actually open up an actual text editor for you to manipulate the text file. And with Git, you can actually set it to do that by default. Even though you can set it up this way, this is actually a great practice for when you maybe need to adjust text on the command line when dealing with a server on Linux and you don't have any graphical user interface to manipulate text.

Okay. So once we're in vi, it's a little difficult to tell exactly what's going on here. If you haven't been in it before, it kind of looks like we have a bunch of back scroll and our cursor has actually been lost.

But if you move your cursor up and down with the arrow keys, you'll see it moving arou ...

In this series we uncover how to use powerful tools to speed up and stabilize the Drupal development process. We begin with a thorough walk-through of Git, the version control system. After we cover how to patch modules and upgrade Drupal from one minor version to another, we demonstrate how to use the Features module to version control components of Drupal that aren't typically available to version control. Finally, we wrap up with how to integrate Drush - a powerful command line tool for Drupal - into your workflow to speed up the process of doing everything we discussed earlier in the series.

Some of the key points we'll be covering include:

How to use the command line

How to work with the Features module to capture important database changes and make deployment easier.

How to use Git for version control

Best practices for working on a Drupal team

Who this collection is for

This video collection is mainly for developers who want to improve their deployment strategies and learn how to work on a shared Drupal code base with other developers. However, even if you are not a developer, our coverage of using Features and version control is extremely valuable for deploying Drupal sites and sharing reusable components between projects.

Prerequisites

Even if you are not a developer, you will be able to follow with most of this collection. When we talk about code we do not go into detail about the basic components of the code, so you may want to brush up on some coding basics in the "PHP Programming Basics" collection.

It looks like there might be an issue playing videos in this browser. We're working on better cross-brower experience, but in the meantime please try the latest Chrome or Firefox browsers. Or, you may be able to watch the video directly without progress tracking or transcript: