How to Learn Vim

or any other large, complex program

Vim is a monster of a program, and it isn’t alone. Linux is chock full of incredibly powerful applications like Vim, emacs, sed, awk, or even bash itself. And learning to use any of these tools well requires a lot of time investment.

I’ve found that a lot of “learn x” resources fit into a pretty common mould. They begin by saying something like, “Vim is a very powerful tool with a steep learning curve, but if you learn to use it you will benefit in all these different ways”. They will then proceed to list out all of the features of the tool:

“Vim is a modal text editor. When you open it you are in command mode (or normal mode, depending on which resource you’re reading), you can enter insert mode to type text like normal, and then press escape to return to command mode. When in command mode, keystrokes are interpretted as commands. Here’s a table of some common ones that you should memorize,”

keystroke command
h move cursor left
j move cursor down
k move cursor up
l move cursor right
i enter insert mode at cursor position
a move cursor to the right and enter insert mode
o create a new line below the cursor, move there, enter insert mode

and so on and so forth.

They might also include some examples of how to use some of these commands. I recall that the book Learning the vi and Vim Editors has a great section where the author provides a block of text with editing corrections, and shows how you can use vi commands to complete all the edits with the minimal amount of keystrokes.

In contrast to this, I still remember the first time that I encountered Vim in a classroom setting. Technically I’d already been using it for some time, because I was one of “those” (I use Arch Linux, btw), but the approach that the instructor took stuck with me.

He introduced the absolute basics: insert mode, command mode, saving the file, and navigation. He then handed out paper copies of the first few pages of Moby Dick, and we had to spend 20 minutes meticulously typing the novel into Vim. Some might call it tedious, but it worked. Even those students who had never used the editor before got used to the idea of modes, and typing text into a terminal. No massive table of Vim commands required.

The basic principle here is that it is better to start using Vim badly, then it is to get overwhelmed and never use it at all. Start slow, and get a handle on the absolute basics first. Once you’re comfortable with this, you can start adding additional commands to your roster.

I’d say a good set of goals for your first couple days with Vim would be as follows:

  1. Learn how to enter insert mode with i and o and leave it with escape
  2. Learn how to use h, j, k, and l to navigate a file.
  3. Learn the basic ex commands for saving, quitting, and searching the file

You’ll want to try to get to a point where these actions are second nature. In particular, the movement may take some time. Your best bet is to manually disable the arrow keys in your .vimrc, to force you to use h, j, k, and l. This will also get you into the habit of navigating the file in command mode, rather than staying in insert mode and using the arrow keys.

Once you feel comfortable with these basics, you’ll be able to use the editor pretty well. Then, start introducing new commands. Pick one that you like: perhaps navigating using w and b, or using the c command rather than backspace to correct a mistyped word. Focus on trying to use that command as much as you can, until it becomes automatic. Then pick another one. And repeat.

The goal here is to gradually achieve fluency. As you add more commands, you will get faster and faster at using the editor. If you haven’t been fully leveraging the navigation functionality of a text editor, it probably won’t take all that long before you’re faster in Vim. And things will get even faster from there.

I’ll admit that this process will not be quick. But, if you teach yourself commands this way, you will actually use them! And that is the key to fluency: not just “knowing” the command, but being able to use it without thinking about it.

Of course, all of this is predicated on you actively using the thing that you are trying to learn. In the case of Vim, it is pretty straightforward. A lot of what we use computers for is text editing. You can write programs, papers, articles, posts, notes, etc., in Vim just as easily as anywhere else. If you’re a student, try using Vim to write all of your papers. If you need to format them in a word processor later, that is fine. But do the original typing in Vim.1

This same process can be applied to many other Linux utilities. Have you been meaning to learn bash keyboard shortcuts for command entry? Just pick one or two and start using them. Want to learn sed? Why not try using it instead of find and replace in your editor? It’s not much, but it is a start. And as you get increasingly comfortable with the tool or command, you’ll start seeing more and more opportunities to use it.

Learning these tools is a long road. To be honest, I am still using this process to try to expand my Vim abilities. I use backspace from insert mode more often than I should, for example, and never use macros for tasks that I almost definitely could use them for. But what fun would life be if you didn’t have any room to improve? One of the great things about Linux and its suite of programs is that they are so large, that you could reasonably spend a lifetime mastering them. There will always be more tricks to learn. And, at least for me, this process has been an effective way to learn some of them.


  1. You may find yourself moving away from word processors and to document formatting systems like groff or LaTex, or maybe a markup language like Markdown. These will allow you to format your documents in Vim as well. But don’t feel pressured to do so. Your goal is to learn Vim, not Vim and a language. ↩︎