Vim Crash Course

It is imperative that you have at least a beginner understanding of how to use vim in order to be able to do your job confidently and effectively. Here’s a 10 minute crash course.

This document was last updated on 20 MARCH 2022

What is vim?

Vim is short for “visual modified.” Vim is a bare bones but extremely powerful text editor that you run in your terminal. You can (and will!) use it to make quick changes to files without having to open them in a separate application.

How do I open a file using vim?

In your terminal, type the command vim ‹file name›.

(Remember that when you see ‹this syntax›, it's a sign to replace everything including the angle brackets with something specific to you. For example, if you want to open a file called configuration you would type vim configuration)

How do I close a file that I’ve opened in vim?

This is one of the most upvoted questions ever asked on StackOverflow. To close vim:

  1. Make sure you aren’t in INSERT mode by hitting the esc key
  2. Type the colon character :
  3. To save your changes, type w for write
  4. To quit the application, type q for quit
  5. Hit enter for the command to take effect

I speak this out loud as “escape colon write quit” — esc :wq

How do I edit a file in vim?

The most basic way to edit a file in vim is to type i to enter INSERT mode. Now you can type in the file. If that’s as far as you get in this tutorial for now, that’s fine.

To exit INSERT mode, hit esc

What are the next vim commands I should learn?

Vim commands can only be typed when you are not in INSERT mode. If you are in INSERT mode, vim will tell you this by putting the word INSERT at the bottom of the screen. To exit INSERT mode, hit esc

Here are some commands I use all the time:

Honestly, that’s enough for now. Everything else you can just do by using the arrow keys to move around. When you eventually get frustrated by that because it’s too slow, find five new commands you want to learn and memorize them.

How can I practice this right now?

"I read that 'real' vim users use hjkl to move the cursor instead of using the arrow keys"

I just truly do not care. The arrow keys are right there and you probably already have good muscle memory about using them. Insiting that there are "right" and "wrong" ways to accomplish simple tasks is gatekeeping. The goal of gatekeepers is to make beginners feel like they don't belong. We ignore gatekeepers. If you like using hjkl, use hjkl. If you like using the arrow keys, use the arrow keys.

Where can I find more help in learning vim?

Linux.com has a nice 101 post on more basic vim commands.

You are smart. You can do this. You have the right and the ability to learn anything you want to learn.